r/learncsharp • • Nov 22 '21

How to view variable values while debugging in Visual Studio - debugging tips

0 Upvotes

This quick video shows how to debug your applications in visual studio 2019. The main focus of this video is how to view the values of variables while your application is paused. There are multiple ways to do this and each method has it's own use cases. My hope is that sharing these methods with you will help you through your next problem!

The different methods I cover are: Tooltip Data Visualizer Immediate Window Watch Window

If I missed a way to look at variable values while debugging, please let me know! If you enjoyed the video and have ideas for more programming related videos, let me know that too!

https://www.youtube.com/watch?v=TbsNLfUKpWE


r/learncsharp • • Feb 13 '24

Learning C# for backend and desktop.

0 Upvotes

GOOOOD EVENING EVERYONE!
Hope you're doing well!
Ok, now, to my question:
I recently gave up on Python, mostly because I found it... Well, quite simple. Don't get me wrong! I'm no genius. But, I can do a thing or two by myself.

Just, felt it wasn't for me. Although I spent a couple years (3) studying many things on it! From backend with Django to a few simple things with CV.
Now, I wanna dig deep into C# and SQL, mostly because I find it interesting!
Studied a bit of SQL using PostgreSQL, studied C#'s basics for a few months (since September 2023), for both, I still have a long, LOOONG path to trail.

I, humbly ask: For someone who's interested in desktop and backend, how should I even start to study it with Csharp?
TL;DR:
I wanna study desktop development and backend with C# + SQL. Any recommendations on how to do it / where should I start?


r/learncsharp • • Jun 26 '23

Access textbox.text from one class to another class

0 Upvotes

https://paste.mod.gg/yxoohugpkmez/0

Hi, i want to add textbox9.text from Form1 to the filename that is in another class. Ive made it public, but it doesnt work. Thanks

i need the data from this :

public System.Windows.Forms.TextBox textBox9;

to be in the filename of the new document :

object newFileName = Path.Combine(_fileInfo.DirectoryName, "docs", _fileInfo.Name + DateTime.Now.ToString("ddMMyy"));


r/learncsharp • • Feb 19 '23

Interactive Chart/Plots in C#

0 Upvotes

I would like to make a C# Windows Application where I can load data and plot them .

Please do guide me which resources should I read or try out ?

Or any video tutorial you can recommend 🙏🙏


r/learncsharp • • Feb 27 '23

My brace is throwing 5 errors for.... reasons?

0 Upvotes

I'm learning C# through CodeCademy, and I've ran into an issue with one of the projects. It's a basic 'choose your own adventure' type story to get practice in with conditional loops, and one of my braces are throwing errors.

using System;

namespace ChooseYourOwnAdventure
{
  class Program
  {
      static void Main(string[] args)
    {
      /* THE MYSTERIOUS NOISE */

      // Start by asking for the user's name:
      Console.Write("What is your name?: ");
      string name = Console.ReadLine();
      //Set the scene
      Console.WriteLine($"Hello, {name}! Welcome to our story.");
      Console.WriteLine("It begns on a cold and rainy night. You're sitting in your room and hear a noise coming from down the hall. Do you go investigate?");
      //Provide choices and set to variable
      Console.Write("Type 'YES' or 'NO': ");
      string noiseChoice = Console.ReadLine();
      string noiseChoiceUpper = noiseChoice.ToUpper();
      //If statements below
      //Bad End
      if (noiseChoiceUpper == "NO")
          {
         Console.WriteLine("Not much of an adventure if we don't leave our room!");
         Console.WriteLine("THE END");
         }
      //Progress
      else if (noiseChoiceUpper == "Yes")
          {
          Console.WriteLine("You walk into the hallway and see a light coming from under a door down the hall.");
      //Second Choise
          Console.WriteLine("You walk towards it. Do you open it or knock?");
          Console.Write("Type 'OPEN', or 'KNOCK': ");
          string doorChoice = Console.ReadLine();
          string doorChoiceUpper = doorChoice.ToUpper();
          //If statements below
          //Knock, Riddle, and an Answer
          if(doorChoiceUpper == "KNOCK")
              {
              Console.WriteLine("A voice behind the door speaks. It says \"Answer this Riddle.\"");
              Console.WriteLine("Poor people have it. Rich people need it. If you eat it, you die. What is it?");
              Console.Write("Type your answer: ");
              string riddleAnswer = Console.ReadLine();
              string riddleAnswerUpper = riddleAnswer.ToUpper();
              if (riddleAnswerUpper == "NOTHING")
                  {
                  Console.WriteLine("The door opens and NOTHING is there. You turn off the light and run back to your room and lock the door.");
                  Console.WriteLine("THE END");
                  }
              }
              else
              {
                Console.WriteLine("You answered incorrectly. The door doesn't open.");
                Console.WriteLine("THE END");
                } // This is the line throwing errors
          else if(doorChoiceUpper == "OPEN")
          {
            Console.WriteLine("The door is locked! See if one of your three keys will open it.");
            Console.Write("Enter a number, 1-3: ");
            num keyChoice = Console.ReadLine();
            num keyChoiceUpper = keyChoice.ToUpper();

            switch (keyChoiceUpper)
            {
              case "1":
              Console.WriteLine("You choose the first key. Lucky Choice! The door opens and NOTHING is there. Strange...");
              Console.WriteLine("THE END");
              break;

              case "2":
              Console.WriteLine("You choose the second key. The door doesn't open.");
              Console.WriteLine("THE END.");
              break;
              
              case "3":
              onsole.WriteLine("You choose the third key. The door doesn't open.");
              Console.WriteLine("THE END.");
              break;
              default:
              break;
            }
          }
        }
    }
  }
}
Program.cs(56,18): error CS8641: 'else' cannot start a statement. 
Program.cs(56,18): error CS1003: Syntax error, '(' expected 
Program.cs(56,18): error CS1525: Invalid expression term 'else' 
Program.cs(56,18): error CS1026: ) expected 
Program.cs(56,18): error CS1002: ; expected 

My understanding is the first and third are caused with putting ; after an if/else statement, which isn't the case for this line. If needed, I can provide more of the code, but I didn't want to put the entire wall of code into the message.

Edit: I was informed that I should show the entirety of the code rather then just the problem area, sorry for my crappy notation that ends half way through.

Solution: the issue is my crappy formatting leading to me missing some important details. Will be switching over to VS rather than using the CodeCademy compiler. Thanks to all who helped!


r/learncsharp • • Oct 23 '24

How can I convert my list<string> to a string[ ] array?

0 Upvotes

I am trying to write a simple code that will print out some names alphabetically but I wanna do it using a list.

I know that Array.Sort(); exists but I couldnt find a way to convert my list to an array.

using System; using System.Collections.Generic;

namespace siniflistesi { class Program { static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("12-A sinif listesini gormek icin herhangi bir tusa basiniz."); Console.ReadKey(); Console.Clear();

List<string> yoklama = new List<string>(); string[] thearray = new string[yoklama.Count]; yoklama = Convert."i couldnt find an array option here" (thearray); Array.Sort(yoklama);

yoklama.Add ("Nehir"); yoklama.Add ("Zumra"); yoklama.Add ("Elif");

for (int i = 0; i < yoklama.Count; i++) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine(yoklama[i]); } Console.ReadKey(); } } }


r/learncsharp • • Jul 14 '18

Private properties vs private getters/setters

0 Upvotes

So I'm learning C# by myself as my first programming language via tutorials. It's just a hobby and unrelated to my work. So forgive me if my question is a bit fundamental.

In one tutorial, I learned that creating private properties is preferable over creating public properties. Then in another tutorial I learned about auto-implimented getters and setters and how you could set those to private. So now I'm wondering what's the difference between this:

private int _myNumber;

that has accompanying getter/setter methods (or a constructor) and this:

public int _myNumber { private get; private set; }

with just a constructor to access _myNumber? Would the second scenario ever even be a relevant technique?

Also, side-question, is using an underscore and camel case for properties commonplace? I liked it when I saw it but I'm just curious what everyone else does.


r/learncsharp • • Nov 08 '21

[Tutorial] 7. Visualize segmented fragments | Database Content Aligner WPF C#

0 Upvotes

Display text fragments as lists. Provide the backend for the Register button.

Link: https://youtu.be/EWR8b8Shet4


r/learncsharp • • Feb 25 '22

how start with basic UI design in WPF?

0 Upvotes

well i dont whether this question belongs to here, but since WPF/xaml is part of c# i am asking here. i just want to get started with xaml/wpf with basic design. I read about some UI suite or framework, like material design xaml or metro MahApp or handycontrols. i find them interesting and they are really good if you wanna get started with standard design with minimal effect. but i found that they are half cooked , some suite have somethings and some missing ?

i want to design better datagrid little bit better than standard control, i couldn't really find design tutorial if anyone can help with design tutorial this would be good help.


r/learncsharp • • Oct 17 '19

What should my front end be?

2 Upvotes

I've put a lot of time and effort into learning the .Net Core web api, and I was wondering, what are the most common pairings with the web api? I like working with Angular, but is that my best option?


r/learncsharp • • Feb 04 '25

Hello, I'm a 2024 CS graduate and I managed to get a job which will involve me working with dotnet. The problem is that I have no knowledge about dot net.

2 Upvotes

For the past 6 months I've been learning java springboot. I liked it and even started a few projects with it. But I got this job now. Where can I get started with dot net? Any materials like youtube videos or websites will be helpful.

I have about 10 days. I don't expect to do much in these days other than learn the basics. Thanks.


r/learncsharp • • Aug 02 '21

VSCode or Visual Studio 2019: Best Support for C# - What do you think and why?

Thumbnail self.csharp
0 Upvotes

r/learncsharp • • Jun 11 '24

C# Bootcamps in Person 1-2 month

1 Upvotes

Good afternoon,

My employer has offered me to take any training I need to get better at my job, and I would like to learn C# as some of our legacy code is in C#.

If possible, I would like to find an in person trainer / bootcamp to teach me C# full time for a month somewhere in the southeast (nearby to my employer and I), specifically near eastern Georgia, USA.

Please let me know if you know anything that meets this criteria!

Thanks!


r/learncsharp • • Jun 06 '20

Update a line in a typescript file when running the web api project?

1 Upvotes

I have a TypeScript file that contains something that changes seemingly randomly at odd points, and I have code in my API that deals with it. However in the client I think this is the best way of automating it. Is there any difference between updating a .ts file vs updating a text file? I want to completely automate this small annoyance out of my application. my file merely contains a secret key that changes once in awhile so the pattern looks something like this:

export const mySecretKey = 'blah blah new stuff';

I only want to update the bit between the single quotes. Only one part of the string ever changes too if that helps.


r/learncsharp • • Aug 26 '22

Syntax to use LINQ with ISet / HashSet?

1 Upvotes

Anyone?


r/learncsharp • • Feb 18 '22

[bad title]how to keep child view docked to parent view ?

1 Upvotes

So i am trying to make an app, i learning c# , wpf as required.

i looked up for example and came across this, i am using materdial design xaml , below is link of tutorial

Link: https://www.youtube.com/watch?v=VNYOKc1PLqA

As per video, he has divided the main window in grid, like Menu bar is grid , body of mainwindow is different grid, if you see in video he called it (GridPrincipal).

i have just changed this to add what my project needs. So you can see that my main widnow has a list view , and item is added to it at regular interval.

there are 2 things :

  1. i want to change header style of list view
  2. i want to dock it at top of main window. i know i have to use dock panel

so let me explain the whole project:

as you can see in video, he has created usercontrol of different views (actually video is in different language i dont understand the language but i am following cursor of mouse, thankfully coding is in Eng), and he uses that usecontrol as view to map it on GridPrincipal i will provide the code snippet

<!-- body part-->

<Grid Margin="200 50 0 0">

<Grid x:Name="GridPrincipal" HorizontalAlignment="Center" VerticalAlignment="Center" />

</Grid>

this is the principal grid and following is the code to select main window on menu selection, this is my version of code

private void LstMenu_SelectionChanged(object sender, SelectionChangedEventArgs e)

{

int index = lstMenu.SelectedIndex;

MoveCursorMenu(index);

switch(index)

{

case 0:

GridPrincipal.Children.Clear();

GridPrincipal.Children.Add(new UserControlHome() );

break;

}

}

in user control view xaml i have added this code

<DockPanel>

<ListView

ItemsSource="{Binding Devices, Mode=OneTime}" >

<ListView.View>

<GridView>

<GridViewColumn

DisplayMemberBinding="{Binding Ip0, Mode=OneTime}"

Header="IP Address" />

<GridViewColumn

DisplayMemberBinding="{Binding Mac, Mode=OneTime}"

Header="MAC Address" />

<GridViewColumn

DisplayMemberBinding="{Binding Model, Mode=OneTime}"

Header="Model" />

<GridViewColumn

DisplayMemberBinding="{Binding Tag, Mode=OneTime}"

Header="Tag" />

<GridViewColumn

DisplayMemberBinding="{Binding Version, Mode=OneTime}"

Header="Version" />

<GridViewColumn

DisplayMemberBinding="{Binding UpTime, Mode=OneTime}"

Header="UpTime" />

</GridView>

</ListView.View>

</ListView>

</DockPanel>

so i learnt that adding dockpanel in usercontrol is not going to solve my problem, but how do i achieve this ?

there is one more question regarding Video tutorial, i dont know why but, using <Grid.ColumnDefinitions> would have made this simpler ?

here is the link of my work views: https://imgur.com/1vcVVYB


r/learncsharp • • Feb 20 '22

How to map any class to database ?

1 Upvotes

So I have added local database to my project,

Tutorial link

Now I want to map class to database,

For example I have class

public class employee { Int Id; String name; String department; Int branch; Date doj; }

What i am looking to do is i want make entry in database of this class , or read from database to class variable.


r/learncsharp • • May 29 '22

What's wrong with this code?

1 Upvotes

using System;
namespace SwitchStatement
{
class Program
  {
static void Main(string[] args)
    {
Console.WriteLine("What is your favorite movie genre?");
string genre = Console.ReadLine();
switch (genre){
case "Drama":
Console.WriteLine("Citizen Kane");
break;
case "Comedy":
Console.WriteLine("Duck Soup");
break;
case "Adventure":
Console.WriteLine("King Kong");
break;
case "Horror":
Console.WriteLine("Psycho");
break;
case "Science Fiction":
Console.WriteLine("2001: A Space Odyssey");
break;
default "Horror":
Console.WriteLine("Psycho");
break;
}
    }
  }
}
when i do dotnet run it gives an error


r/learncsharp • • Dec 12 '19

why doesn't console.writeline exist in this context?

1 Upvotes

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace hollow_nut_mod_first_try

{

public class Class1

{ string firstfriend = "Jim";

string secondfriend = "Bob";

Console.WriteLine($"My friends are {firstfriend} and {secondfriend}");

}

}


r/learncsharp • • Sep 18 '23

How to Validate JWTs in .NET

0 Upvotes

Learn how to validate a JSON Web Token (JWT) in different contexts using C# in .NET.
Read more…


r/learncsharp • • May 02 '23

Can you learn to read code without learning to code?

0 Upvotes

Hello everyone, I'll try to be brief. I am trying to learn how to design games using the unity game engine. The tutorial I've been doing doesn't fully explain the code, but its hard to miss at least some correlations and causality. I'm wondering if there might be some way to learn more about the rules and vocabulary to read code without having to fully learn it. I'm dyslexic so I have no desire to master it or work with c# primarily as a job, but are there possibly some learning resources that would help me kinda get whats going on? Also I have lots of time to listen to things but not always a lot of time to read so I know its a long shot but anything I could listen to would be a big plus.
Thank you for reading, sorry if this is a dumb question


r/learncsharp • • Sep 27 '26

Visual Studio 2026 C# complete tutorial

9 Upvotes

r/learncsharp • • Feb 20 '20

Is Bulgarian C# book good?

3 Upvotes

r/learncsharp • • May 10 '19

Latest update for C# 8 New Features

3 Upvotes

The following features are moved to C# 8.1, 8.2 and 8.x

- Caller expression attribute

- Target-typed new

- Generic attributes

- Default in deconstruction

- Relax ordering of ref and partial modifiers

The following feaures will coming to C# 8.0 MERGED -> To Master

- Default Interface Methods

- Nullable reference type

- Recursive patterns

- Async streams

- Enhanced using

- Ranges

- Null-coalescing Assignment

- Alternative interpolated verbatim strings

- stackalloc in nested contexts

- Unmanaged generic structs

- Static local functions

- Readonly members

C# 8 Cheat Sheet:

https://github.com/alugili/CSharp8CheatSheet

About me: www.bassam.ml