MODiX
MODiX
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
If you have no further questions, please use /close to mark the forum thread as answered
32 replies
CC#
Created by Nicholas on 12/17/2024 in #help
Can't assign private variable (Unity)
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!
32 replies
CC#
Created by OrangeHokage on 12/17/2024 in #help
XAML UI Preview on Visual Studio
Rules of WPF:

❌ Avoid the WPF Designer to eliminate a category of confusing bugs
❌ Don't rely on Margin as the primary tool for layouts
❌ Avoid writing UserControls or subclassing to extend a default control -- use Behaviors instead (Microsoft.Xaml.Behaviors.Wpf)

✅ Write XAML by hand and autoformat with "Ctrl K,D" or XAML Styler
✅ Rely upon XAML Hot Reload to design your app's UI at runtime
✅ Use layout controls (Grid, DockPanel, etc) to support proper resizing
✅ Use data binding to eliminate glue code and state synchronization issues
✅ Use collection controls and DataTemplate to dynamically create lists of controls
✅ Learn MVVM to create maintainable apps
✅ Use the Dispatcher to update controls from non-UI threads
✅ WPF's default controls can be easily modernized via $wpfuilibs
✅ Include relevant XAML, code-behind, and ViewModel code for questions when possible
Rules of WPF:

❌ Avoid the WPF Designer to eliminate a category of confusing bugs
❌ Don't rely on Margin as the primary tool for layouts
❌ Avoid writing UserControls or subclassing to extend a default control -- use Behaviors instead (Microsoft.Xaml.Behaviors.Wpf)

✅ Write XAML by hand and autoformat with "Ctrl K,D" or XAML Styler
✅ Rely upon XAML Hot Reload to design your app's UI at runtime
✅ Use layout controls (Grid, DockPanel, etc) to support proper resizing
✅ Use data binding to eliminate glue code and state synchronization issues
✅ Use collection controls and DataTemplate to dynamically create lists of controls
✅ Learn MVVM to create maintainable apps
✅ Use the Dispatcher to update controls from non-UI threads
✅ WPF's default controls can be easily modernized via $wpfuilibs
✅ Include relevant XAML, code-behind, and ViewModel code for questions when possible
13 replies
CC#
Created by Richard01_CZ on 12/15/2024 in #help
Issues loading DLL
Please don't upload any potentially harmful files @Richard01_CZ, your message has been removed
18 replies
CC#
Created by stigzler on 12/2/2024 in #help
Sloppy Constructors
8 replies
CC#
Created by Kushiwushi on 12/13/2024 in #help
Ending of curly braces results in an error?
* close VS * remove the hidden folder .vs * remove all bin and obj folder next to each csproj (DO NOT TOUCH THE .git FOLDER OR WHAT'S INSIDE) * restart vs
13 replies
CC#
Created by Tyler on 12/13/2024 in #help
Advice for learning C# (Beginner - New to C# not programming)
5 replies
CC#
Created by Gunshot on 12/12/2024 in #help
✅ C# TCP connections Help
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
4 replies
CC#
Created by Amir on 12/12/2024 in #help
Which .NET UI platform to use?
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework. .NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended. https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
8 replies
CC#
Created by Amir on 12/12/2024 in #help
Which .NET UI platform to use?
8 replies
CC#
Created by Izsák on 12/11/2024 in #help
hello everyone im trying to make a 2d topdown game in unity and the script i wrote isn't working
55 replies
CC#
Created by moonbat on 12/11/2024 in #help
My Visual Studio code keeps making this error
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
4 replies
CC#
Created by seky16 on 12/9/2024 in #help
records, with expression, required property
15 replies
CC#
Created by seky16 on 12/9/2024 in #help
records, with expression, required property
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!
15 replies
CC#
Created by a on 12/9/2024 in #help
Need help with text files
401 replies
CC#
Created by Mihneas22 on 12/9/2024 in #help
Get values from appsettings in .NET Core
appsettings.json:
{
"My": {
"Foo": {
"Kix": 5
}
}
}
{
"My": {
"Foo": {
"Kix": 5
}
}
}
src/Foo/FooOptions.cs:
public class FooOptions
{
public const string SectionName = "My:Foo";

public string Bar {get;set;} = "default value for bar";
public int Kix {get;set;} = -1;
public DateTime? Pouet {get;set;} = default;
}
public class FooOptions
{
public const string SectionName = "My:Foo";

public string Bar {get;set;} = "default value for bar";
public int Kix {get;set;} = -1;
public DateTime? Pouet {get;set;} = default;
}
src/Foo/FooServiceCollectionExtensions.cs:
namespace Microsoft.Extensions.DependencyInjection; // <==== recommanded for service.Add so that you don't clutter Startup file

public class FooServiceCollectionExtensions
{
public static IServiceCollection AddFoo(this IServiceCollection services) =>
services
.AddOptions<FooOptions>()
.BindConfiguration(FooOptions.SectionName)
.Validate(options => options.Kix >= 0, $"The configuration key '{FooOptions.SectionName}:{nameof(Kix)}' cannot be negative")
;

public static IServiceCollection AddFoo(this IServiceCollection services, Action<FooOptions> configure) =>
services
.AddFoo()
.Configure(configure);
namespace Microsoft.Extensions.DependencyInjection; // <==== recommanded for service.Add so that you don't clutter Startup file

public class FooServiceCollectionExtensions
{
public static IServiceCollection AddFoo(this IServiceCollection services) =>
services
.AddOptions<FooOptions>()
.BindConfiguration(FooOptions.SectionName)
.Validate(options => options.Kix >= 0, $"The configuration key '{FooOptions.SectionName}:{nameof(Kix)}' cannot be negative")
;

public static IServiceCollection AddFoo(this IServiceCollection services, Action<FooOptions> configure) =>
services
.AddFoo()
.Configure(configure);
Program.cs / Startup.cs:
services.AddFoo();
// or
services.AddFoo(fooOptions => fooOptions.Kix = 12);
services.AddFoo();
// or
services.AddFoo(fooOptions => fooOptions.Kix = 12);
Bar.cs:
public class Bar
{
private readonly FooOptions _fooOptions;

// .Value in ctor is fine only if it's always ever a non-changing value (no reload and/or no scoped resolution)
public Bar(IOptions<FooOptions> fooOptions)
=> _fooOptions = fooOptions.Value;
}
public class Bar
{
private readonly FooOptions _fooOptions;

// .Value in ctor is fine only if it's always ever a non-changing value (no reload and/or no scoped resolution)
public Bar(IOptions<FooOptions> fooOptions)
=> _fooOptions = fooOptions.Value;
}
8 replies
CC#
Created by seky16 on 12/9/2024 in #help
records, with expression, required property
15 replies
CC#
Created by donteventry143 on 12/5/2024 in #help
I am a total beginner to C# and OOP, I created a project...
20 replies