Press J to jump to the feed. Press question mark to learn the rest of the keyboard shortcuts
Found the internet!
r/csharp
16
Posted by1 month ago

WinUI or .NET MAUI?

I'm thinking to develop a note taking app. Am confused, which one I should go for? WinUI? MAUI? I'm not sure whether the app will be cross platform or not. probably it will be exclusive to windows only. Still should I choose MAUI or WinUI is fine? I have to learn both of the frameworks from the scratch, so which one I should choose?

25 comments
84% Upvoted

User avatar
level 1

If it's Windows-only, WinUI is the better choice of these two. MAUI is made for cross-platform, which means some things won't be as straightforward as you might think because they have to be designed with iOS and Android in mind as well as Windows. It's also sort of troublesome to get going in MAUI right now because a ton of packages that supported Xamarin are "supporting MAUI" but not Windows projects yet. (Looking at you, System.Reactive.)

17
User avatar
level 2

Ah, ok. So better to avoid MAUI untill we cross platform development?

1
User avatar
level 1

If cross platform Maui. If windows only winui.

Fwiw Maui isn't ready for prime time yet.

8
User avatar
level 2

Not ready in what way(s)?

2
User avatar
level 2

Ok, thanks buddy, helpful. going with WinUI

1
User avatar
level 1

For a very comprehensive overview of all the desktop app choices, I highly recommend this video— https://youtu.be/8NdJaztrNk8

Skip the first 5 minutes to dive in after the intros. Plenty of really good info to help you make your choice

7
User avatar
level 2

Really thanks for the video buddy. just checking it out. :-)

2
User avatar
level 1

probably it will be exclusive to windows only

Then don't go with MAUI. MAUI is a mobile-first framework where Windows and macOS only exist as an afterthought.

If you want a desktop-first cross-platform framework, take a look at Avalonia.

2
User avatar
level 2

Ok, I was checking Avalonia, but it seems that it is not accessible for screen readers :( And I have to develop the app for blind people

1
User avatar
level 1

Wait, there’s an alternative to WinForms that isn’t XAML?

2
User avatar
level 2

I'm talking about frameworks. I know XAML obviously

1
User avatar
level 1

Build it with WinUI on windows and then you can get it working on other platforms with Uno Platform

2
User avatar
level 2

Ok :-) thanks bro

2
User avatar
level 1

Avalonia? I think WinUI still need a bunch of weird shit like uwp tools, manifest files, and other garbage

2
level 2
· 1 mo. ago
MSFT - Microsoft Store team, .NET Community Toolkit

You don't have to use a manifest, you can also create an unpackaged WinUI app. But also, why would you consider the manifest garbage in the first place? Packaged apps have pretty obvious benefits for consumers compared to unpackaged ones.

3
level 2

Never tried Avalonia actually. Is it better then WinUI? and how is the learning curve? Also, is it accessible for screen readers? :-)

1
level 1

wpf/avalonia

2
level 2

Does Avalonia has UI designer too?

1
level 1
[deleted]
· 1 mo. ago

[削除されました]

-1
level 2

Yes, but I don't want to make it kind of a web app.

2
level 1

If it's for fun/study, go with MAUI. You have an idea for the end product, there's tons out there already for every platform already. Why not use this as an opportunity to learn. MAUI might not be big now, but there's a real chance in 3-5 years it might be a very common platform due to it's write once run anywhere approach. And with a note taking app, something that would be useful on Mac, iOS, Windows, and Android... it screams "run me everywhere!"

1
level 2

Ya, that's a good idea. Will try to learn MAUI after some months, right now this app is quite important for me as I'm working on WinUI for now. but definitely, I need to develop it for cross platform later on

1
More posts from the csharp community
232
Posted by12 hours ago
Post image
232
72 comments
153
Posted by3 days ago
Post image

i haven’t highlighted the character what’s so ever, I have only left clicked on the character.

153
79 comments
130
130
20 comments
93
93
54 comments
88
Posted by5 days ago
88
181 comments
67
Posted by6 days ago
67
15 comments
50
50
4 comments
47
Posted by1 day ago

As an update from this thread, I ended up going with Jint JavaScript interpreter for my program's scripting feature. The runner-up is Nlua which actually seems to be the preferred choice. If Jint doesn't work out for some reason, I will try Nlua. Also, for template rendering, there is scriban and Handlebars, one of which I'll use for the template that displays the room description, contents, exits, etc.

But, anyway, on to the cool part which is a demo of my program's first scripted event! In this demo, I follow these steps:

  1. Begin outside the white house from Zork 1

  2. Open the mailbox and read the note inside

  3. Close the mailbox

  4. Go into edit mode and edit the mailbox

  5. Add an event that will fire when I invoke an OPEN action on the mailbox

  6. Add an event handler that will execute this script:args.CancelCurrent = true;args.Message = "As soon as the lid to the mailbox begins to open, it snaps shut!";

args is passed in from the event manager. CancelCurrent = true cancels the event so that the mailbox does not open and also displays a special message.

Once I got this working, it was the coolest thing, and it only required a few extra lines of code. Thanks to everyone who offered their help in that other thread!

Edit: This was originally an animated GIF, but got converted to a video. Click on it and you can seek through it if you missed a part.

https://i.redd.it/mg196e8zj5g91.gif
47
1 comment
45
Posted by7 days ago

I have been a c# developer for last 8 yrs now. I know all the theories. I have done 20 plus courses on various topics in c#. I have watched almost all videos of Iamtimcorey YouTube channel. Many from NickChapsas as well. While watching videos it makes perfect sense and i can able to understand everything. But when a taak is given to me i have no idea how to start. Where to implement the theory in what features. Someone if told me what to do, then i am more than capable of doing that. I have problem of doing on my own. I am struggling to put all the theories to solution. That’s why I struggle in the coding round in the interview. Kindly help.

45
88 comments
42
Posted by2 days ago

I am writing an interactive fiction builder where users can build their own games. There will be times when scripting will be required. For example, my builder supports adding custom attributes to game objects, so you could create a lantern object and annotate it with "type = lightsource" and "isactive = false". Before displaying a room's contents, the game author could write a script like:

void OnDisplayRoomContents(args a) {
    if (
        a.Area.Attr("isdark") == true && 
        !Player.Items.Any(x => 
            x.Attr("type") == "lightsource" &&
            x.Attr("isactive) == true
        )
    ) {
        a.Display = false;
    }
}

Basically, if the player is in a dark room and they don't have an active light source, don't display the room contents (or display something else like "You're likely to be eaten by a grue").

I've just discovered the Microsoft.CSharp.CSharpCodeProvider namespace which is included in c#, but there is also apparently IronPython. There are probably others. I will also need to evaluate/validate the scripts to prevent malicious code (don't want anyone writing code to delete someone's System32 folder).

Looking forward to good suggestions.

42
46 comments
40
Posted by4 days ago

Quite the conundrum, I am not sure which one to use when... What's your rule of thumb?

40
115 comments
37
Posted by4 days ago

Other than SQL/C# and the bare basics of knowing how ASP.NET works, what are the things that a new webapp/webdev backend C# programmer is expected to know?

I was checking the job market for non webdev related jobs outside of unity and found practically nothing for things like maui/xamarin/wpf.

37
18 comments
35
Posted by6 days ago

A link to the Repository:

https://github.com/huntercfreeman/BlazorStudio


Make sure to clear your cache for the latest demo: https://hunter-freeman-dev.azurewebsites.net/

35
6 comments
32
Posted by6 days ago

JavaScript and Python seem to have all the buzz right now, does it seem like c# is underrated? Or ought to be more popular for the career opportunities and uses it has? glad to hear any feedback

32
56 comments
31
Posted by1 day ago

Everything that I imagine using local functions for, there's pre-existing way of coding that would function just as well without the language feature. I don't find that it's more readable.

I find it just derails the readability of code.

31
63 comments
31
Posted by1 day ago
Platinum

I have a List<T> and i want it to have no duplicates, I have tried the following:

1- Converting the list to HashSet

var listWithoutDuplicates = new HashSet<T>(listWithDuplicates).ToList();

but i still get duplicate values

2- not adding the object if it already exists

foreach(var item in llistWithDuplicates)
{
    if(listWithoutDuplicates.Contains() == false)
    {
        listWithoutDuplicates.Add(item);
    }
}

3- Adding `.Distinct()` after the list like so

listWithDuplicates = listWithDuplicates.Distinct().ToList();


But with no luck in all my attempts, i am trying to filter the list before inserting into a DB using EF, Thanks in advance.

Edit: Thanks for the platinum, i got my answer and my first platinum. I’ll be sure to keep asking questions for the things i struggle with during work here, you guys are awesome!

31
49 comments
31
Posted by4 days ago

I had a design where a ‘Func’ ist set from outside, those func is returning a task, that I need to wait for once a specific trigger (like message via channel) has happen. So I thought I just use the task returned an call GetAwaiter().GetResult() and were hoping it will start the task internal:-/ after I find that it clear why it doesn’t throw an exception, because the task may be started from somewhere else. it was obvious my mistake but I was shocked that there was no warning or something similar, pointing me to my mistake…

Yeah now I learned, to call task.Run() or task.Start() before the GetAwaiter().GetResult()

31
19 comments
31
31
1 comment
26
Posted by7 days ago

I want to create full stack web project. The problem is that I don't like js and I would like to avoid him and use blazor instead. I did some simple projects with blazor but is it good and sufficient for more complex projects and can replace angular or react?

26
35 comments
25
Posted by4 days ago
25
1 comment
25
Posted by4 days ago

I have some experience with C# in Unity, but I want to learn to make "normal" programs with C# (which as far as i know is with .net). It's not for anything in particular, I just want to practice a little bit of programming outside of Unity (and I got tired of python lol). I'm still pretty much a beginner, but I don't want to sit through a 6 hour course that teaches me what ✨variables✨ and ✨functions✨ are again, just learn enough to use C# without the need of GetComponent and stuff (or guessing my way through it and making horrible spaghetti code), learn how to use namespaces and all that, maybe make graphical things kinda like pygame or something, if that makes any sense

25
25 comments
24
Posted by2 days ago

Here is an example. I have to await for the DBSet to add the user and then i can save it to the database and then return the user object back. Does async even make sense in this case?

[HttpPost]
public async Task<IActionResult> Insert(User user)
{
    try
    {
        await _context.Users.AddAsync(user);
        await _context.SaveChangesAsync();
        return Ok(user);
    }
    catch (Exception ex)
    {
        return Problem(ex.InnerException?.Message);
    }
}
24
55 comments
20
Posted by3 days ago

Hello, I'm a C# beginner learning through w3chools's course I just read a bit about creating methods to reuse code, so I did this to practice a bit.

Any suggestions are welcome, thanks in advance

Code:

 static void Main(string[] args)
        {   
             Console.WriteLine("----------------------------");
            TheCalculator();
            Console.WriteLine("\nPress Y to continue");
            bool keyCheck = KeyRead() == 'Y';
             
            while (true)
            {
            
                if (!keyCheck)
                {
                    break;
                }
                
                TheCalculator();
            Console.WriteLine("\nPress Y to continue"); 
            keyCheck = KeyRead() == 'Y';
            }

        }   
        
        static double CheckNumber(string numString)
        {
            while(true)
            {
                
                double numDoubleTest;
                if (double.TryParse(numString, out numDoubleTest))
                {
                    break; //if it can parse to number breaks the loop
                }
                Console.WriteLine("Not a number \n Try again");
                numString = Console.ReadLine();
            }
            int numDouble = Convert.ToInt32(numString); //normal convertion
            return numDouble;//variable

        }
        static void TheCalculator()
        {
            Console.WriteLine("Power calculator");
            Console.WriteLine("----------------------------");
            Console.WriteLine("Please, insert a number");
            double baseNumber = CheckNumber(Console.ReadLine());
            
            Console.WriteLine("Please insert an exponet");
            double exponetNum = CheckNumber(Console.ReadLine());
            double result = Math.Pow(baseNumber,exponetNum);
            Console.WriteLine("result is : "+ result);
        }
        static char KeyRead()
        {
            var inputKey = Console.ReadKey();
            string inputKeyString = Convert.ToString(inputKey.KeyChar);
            inputKeyString = inputKeyString.ToUpper();
            char inputKeyChar = Convert.ToChar(inputKeyString);
            return inputKeyChar;
            
        }

The exercise:


https://i.redd.it/r786tn1hkpf91.png
20
66 comments
20
Posted by4 days ago

I want to disable garbage collection whenever heap usage is below 256 megabytes to minimize GC pauses. Is the're a way to do this?

20
16 comments
Continue browsing in r/csharp

About Community

Welcome to csharp
204k

C# devs

144

null reference exceptions


Created Mar 10, 2008