fæ
CC#
Created by on 11/20/2024 in #help
overriding methods
I have multiple questions: 1) What is the benefit of declaring a base method as virtual before overriding it in an inheriting class? This is my understanding: it allows calling the override despite casting to the base class. Is this correct? 2) What is the difference between overriding a method, and hiding a method? As in, what does the new keyword do exactly?
90 replies
CC#
Created by on 11/19/2024 in #help
Declaring a struct as a constant
No description
19 replies
CC#
Created by on 11/18/2024 in #help
job advice
ok so i just passed some offline technical tests for a asp.net backend dev job. but honestly, while i'm quite experienced with C# as a WPF dev i dont know much about asp.net and havent really developed anything using it. i might have an interview in a week again, so can you prime me on what i should learn in this week? as fast as possible, i want to get as much knowledge.
2 replies
CC#
Created by on 10/8/2023 in #help
❔ how to create a class equivalent to another
No description
46 replies
CC#
Created by 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 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 on 10/6/2023 in #help
❔ how to use "with"
No description
48 replies
CC#
Created by on 10/6/2023 in #help
❔ Difference between public property with protected setters and getters and protected property?
q
8 replies
CC#
Created by 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 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 on 10/6/2023 in #help
✅ C# best practices clarification
No description
16 replies
CC#
Created by on 10/6/2023 in #help
✅ What does this property do?
No description
130 replies
CC#
Created by 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