MODiX
MODiX
CC#
Created by MechWarrior99 on 1/18/2025 in #help
Would a Declarative Reactive UI be too expensive?
39 replies
CC#
Created by Faker on 1/18/2025 in #help
when to use var keyword and when to use data type itself
28 replies
CC#
Created by HeckerMaster on 1/18/2025 in #help
✅ Run the program as administrator without unnecessary windows
If you have no further questions, please use /close to mark the forum thread as answered
8 replies
CC#
Created by Faker on 1/18/2025 in #help
Casting and Convert method in C#
61 replies
CC#
Created by Faker on 1/18/2025 in #help
Casting and Convert method in C#
61 replies
CC#
Created by Faker on 1/18/2025 in #help
Casting and Convert method in C#
When you don't know if a string is actually a number when handling user input, use int.TryParse (or variants, e.g. double.TryParse)
if (int.TryParse("123", out int number))
{
var total = number + 1;
Console.WriteLine(total); // output: 124
}
if (int.TryParse("123", out int number))
{
var total = number + 1;
Console.WriteLine(total); // output: 124
}
TryParse returns a bool, where true indicates successful parsing. - Avoid int.Parse if you do not know if the value parsed is definitely a number. - Avoid Convert.ToInt32 entirely, this is an older method and Parse should be preferred where you know the string can be parsed. Read more here
61 replies
CC#
Created by Gasper 1.0 on 1/17/2025 in #help
why is my code weird??
If intellisense is not working for Rider / Visual Studio, follow these steps.
Go into Unity Editor -> Preferences -> External Tools -> Set Visual Studio (or JetBrains Rider) as your preferred editor.
Go into Unity Editor -> Preferences -> External Tools -> Set Visual Studio (or JetBrains Rider) as your preferred editor.
Close the editor and re-open it again by double-clicking a script file.
26 replies
CC#
Created by Gasper 1.0 on 1/17/2025 in #help
why is my code weird??
26 replies
CC#
Created by Faker on 1/16/2025 in #help
Properties vs Fields in C#
class Foo
{
private int _bar;

public int GetBar()
{
return _bar;
}

public void SetBar(int bar)
{
_bar = bar;
}
}
class Foo
{
private int _bar;

public int GetBar()
{
return _bar;
}

public void SetBar(int bar)
{
_bar = bar;
}
}
can be shortened to
class Foo
{
private int _bar;

public int GetBar() => _bar;

public void SetBar(int bar) => _bar = bar;
}
class Foo
{
private int _bar;

public int GetBar() => _bar;

public void SetBar(int bar) => _bar = bar;
}
can be shortened to
class Foo
{
private int _bar;
public int Bar {
get { return _bar; }
set { _bar = value; }
}
}
class Foo
{
private int _bar;
public int Bar {
get { return _bar; }
set { _bar = value; }
}
}
can be shortened to
class Foo
{
private int _bar;
public int Bar {
get => _bar;
set => _bar = value;
}
}
class Foo
{
private int _bar;
public int Bar {
get => _bar;
set => _bar = value;
}
}
can be shortened to
class Foo
{
public int Bar { get; set; }
}
class Foo
{
public int Bar { get; set; }
}
16 replies
CC#
Created by Faker on 1/16/2025 in #help
Properties vs Fields in C#
Why use properties over a public field? - Properties can individually specify access modifiers for get and set - With Visual Studio, you can type prop, press tab and it will auto complete for you - XAML requires properties for bindings - Field exposure is really only done in readonly structs - Using properties allows for future changes to the getter or setter without breaking your API/external programs (binary compatibility) Example of an auto property:
class Example
{
public string Name { get; set; }
public int Age { get; set; }
}
class Example
{
public string Name { get; set; }
public int Age { get; set; }
}
Example of a property with backing field:
class Example
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}

private int _age;
public int Age
{
get { return _age; }
set { _age = value; }
}
}
class Example
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}

private int _age;
public int Age
{
get { return _age; }
set { _age = value; }
}
}
16 replies
CC#
Created by 77_105_114_111 on 1/16/2025 in #help
✅ Ignore case sensitive string in array.
If you have no further questions, please use /close to mark the forum thread as answered
14 replies
CC#
Created by The Negative One on 1/15/2025 in #help
Convert List to index to be used in an array
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
52 replies
CC#
Created by /Mr.Ares77 on 1/15/2025 in #help
How to update mysql server data?
45 replies
CC#
Created by antessq on 1/15/2025 in #help
hello
54 replies
CC#
Created by antessq on 1/15/2025 in #help
hello
Get started in 3 high level steps... 1. Download Visual Studio Community if you're on Windows or VS Code if you're on Mac/Linux 2. Set up your development environment in Visual Studio or VS Code 3. Get started with videos or interactive tutorials
54 replies
CC#
Created by workani on 1/15/2025 in #help
✅ Implementing delete repository method & controller | Web Api
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, what you expect the result to be, what .NET version you are using and what platform/environment (if any) are relevant to your question. Upload code here https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code! (see $code for more information on how to paste your code)
29 replies