faetalize
faetalize
CC#
Created by faetalize on 10/8/2023 in #help
❔ how to create a class equivalent to another
No description
46 replies
CC#
Created by faetalize on 10/7/2023 in #help
✅ filling byte array with a random int
best approach?
BinaryPrimitives.WriteInt32BigEndian(bytes, Random.Shared.Next(5000000));
//vs
bytes = BitConverter.GetBytes(Random.Shared.Next(5000000));
BinaryPrimitives.WriteInt32BigEndian(bytes, Random.Shared.Next(5000000));
//vs
bytes = BitConverter.GetBytes(Random.Shared.Next(5000000));
15 replies
CC#
Created by faetalize on 10/7/2023 in #help
❔ picking the right patterns
class Human{
public int age { /*custom get n set*/ }
}

Human h = new Human();
h.age++;
class Human{
public int age { /*custom get n set*/ }
}

Human h = new Human();
h.age++;
vs
class Human{
public int age { get; protected set; }
public grow() { age++; }
}

Human h = new Human();
h.grow();
class Human{
public int age { get; protected set; }
public grow() { age++; }
}

Human h = new Human();
h.grow();
21 replies
CC#
Created by faetalize on 10/6/2023 in #help
❔ how to use "with"
No description
48 replies
CC#
Created by faetalize on 10/6/2023 in #help
❔ Difference between public property with protected setters and getters and protected property?
q
8 replies
CC#
Created by faetalize on 10/6/2023 in #help
❔ what's a usecase where "readonly" would be prefered to property with an init setter?
init can be used in both constructor and in object initializers. readonly only in constructor.
12 replies
CC#
Created by faetalize on 10/6/2023 in #help
❔ `required` keyword
what is the purpose of the required keyword when we can enforce a property to be set through the constructor?
31 replies
CC#
Created by faetalize on 10/6/2023 in #help
✅ C# best practices clarification
No description
16 replies
CC#
Created by faetalize on 10/6/2023 in #help
✅ What does this property do?
No description
130 replies
CC#
Created by faetalize on 10/6/2023 in #help
❔ ✅ why properties instead of public fields
in this case
class Person
{
public int age;
//vs
public int Age {get; set;}
}
class Person
{
public int age;
//vs
public int Age {get; set;}
}
58 replies