SoftwareEngineer666👿⸸⸸⸸
SoftwareEngineer666👿⸸⸸⸸
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
Never used avalonia but it seems to be popular :). Ok
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
so a property in one class can be another class.
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
you can also nest objects with it.
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
once you get the hang of parsing json using DataContract it's really easy. Just play with it till you get the hang of it :). When you write a class and decorate properties with DataMember you have to remember to provide a set method too. It requires that even if you're serializing it. You can make the set method protected.
79 replies
CC#
Created by duaalk on 3/16/2024 in #help
Lambda expression and arrow function
Yes. If you want to parse lambda's around in C# you can either write a delegate or you can use built in Action and Func delegates. The last generic provided to Func is the return type. Action has no return type. So for example Action<string, int> theMethod = (aString, anInt)=>{ ...Do something}; Func<string, bool> = (stringIn)=>{ do something..... return true}; kinda thing. Or you could write a delegate public delegate bool MyDelegate(string aParameter, long anotherParameter); and use it like MyDelegate d = (aString, anotherParameter)=> { .... do something}. And you can miss off the curley brackets if you can write the function in a single line. If you want to use ref and out, you can do that if you write a delegate. But Action and Func wont let you do that.
4 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
its really not. You're going to need json to speak to servers through websockets and for configuration files and stuff anyway 🙂
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
🙂
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
new NativeJsonParser().Deserialize<Example[]> (theJsonString);
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
you could parse it like this
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
suppose you have this json [{"username":"dfdffd", "password":"fdfddf"}, {"username":"anotheruser", "password":"dfdfdf"}]
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
namespace Chat.Messages.Client.Messages { [DataContract] public class Example { [DataMember(Name = "username")] public string Username { get; protected set; } [DataMember(Name = "password")] public string Password { get; protected set; } } }
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
if the outside of your json uses square brackets. That's a list or array right. So for example Suppose we have this class:
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
This is a wrapper I made for Serializing and Deserializing objects to from json
79 replies
CC#
Created by Mekasu0124 on 3/16/2024 in #help
✅ Can't figure out json logic
here i will show you how to do it. You can use DataContract and DataMember
79 replies