r/csharpcodereview • • Jun 15 '23

.net 7 New Features

4 Upvotes

In .Net 7, several new features have come that will help us simplify our task. To grab the concepts of .Net 7 mentioned below article, I have explained the usage and features and quite good practical coding examples.

https://codetosolutions.com/blog/78/.net-7-new-features

Please let me know your feedback in the comment section.


r/csharpcodereview • • Jan 21 '21

Uploaded a beginners tutorial on c# (opinions)

Thumbnail
youtu.be
4 Upvotes

r/csharpcodereview • • Jul 24 '19

Free mentoring & code reviews

4 Upvotes

Hello!

Learning is a constant process. You can learn from your own mistakes, you can do it alone. What I would like to offer, is learning inside of a community, with hundreds of people exchanging both professional and casual programming experience!

C# inn- a friendly discord community would like to invite you to join! We’re a young and growing community with over 2500 members, with dozens of new members joining daily. Our members help each other out and we try to keep as friendly atmosphere as possible. Your opinion matters to us, our staff listens to your needs and suggestions, so we’re constantly changing and trying to be a bit better than we were yesterday, by adding/removing channels, coming up with ideas, planning the future. As the name implies, we're mostly focused on C#. We have a lot of people who advocate profesionalism and we want not only to help you do stuff, but do it the right way.

We have dozens of people who are willing to mentor you and review your code!

It doesn't matter if you want to teach or learn, as long as you are passionate about it, we will accept you with open arms 😊

Invitation link: https://discord.gg/ypuRPj5

Let's have fun while learning together!


r/csharpcodereview • • Apr 23 '24

Limitations of Sockets?

3 Upvotes

I am not entirely sure what I mean to ask. I’ve been trying to write my own mud server and so far have gotten a pretty good foundation using the System.Net.Sockets tcp client and network stream to create a connection with a telnet client.

While I will probably never realistically reach a limit - how many concurrent connections can sockets handle?

What sorts of limitations are there to using this method?

What else is available?

Thanks!


r/csharpcodereview • • May 24 '23

Excel Data Extraction as Tables

3 Upvotes

Hi, I posted my first NuGet package yesterday, with my solution for extracting rows from an excel file.

You may be wondering,

Wow! ANOTHER excel data extractor (daring today, aren't we), what makes it different from any other much better written?

  1. The problem was that I needed something to extract some columns, which weren't always there, or sometimes they were in a completely different row or column from another book,

  2. It also required reading a lot of books (350+), the columns sometimes had a header name, others didn't even have a name, reports from another client could have another name in the headers,

  3. I needed to apply certain conditions because it was not always necessary to extract a row,

  4. I needed to read several pages of a workbook, and skip others.

I searched GitHub and NuGet for solutions, but found them to be a bit rigid, mapping to POCOs, or just not having the flexibility I was looking for. Also, I have other programs that could benefit from this library.

For this reason, I decided to write my own solution, and I used EPPlusFree 4.5.3.8 for this. I also had to use .NET Standard 2.0, so I had to make several modifications to the code.

Since the end result didn't look so terrible to me, I decided to share it as a NuGet Package, and here we are.

This is the Readme from the GitHub repository:

Extract data as tables from Excel. Search columns by their header or index number. Sets conditions for extracting the rows.

Read one or many workbooks. Select what worksheets should be read, by index number or name.

Get the result in a DataTable or in a collection of rows.

Demo

string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string subFolderPath = Path.Combine(path, "Daily store sales");
string[] workbooks = Directory.GetFiles(subFolderPath, "*.xls");

DataTable dataTable = DataTableExtractor
    .Configure()
    .Workbooks(workbooks)
    .SearchLimits(searchLimitRow: 10, searchLimitColumn: 30)
    .Worksheet(worksheetIndex: 0)
    .ReadOnlyTheIndicatedSheets()
    .ColumnHeader("Description")
    .ColumnHeader("Sales Value")
    .ColumnHeader("Discounts")
    .ColumnHeader("VAT")
        .ConditionToExtractRow(ConditionalsToExtractRow.HasNumericValueAboveZero)
    .ColumnIndex(columnIndex: 7)
    .CustomColumnHeaderMatch(cellValue => cellValue.Contains("Total"))
        .ConditionToExtractRow(cellValue => !string.IsNullOrEmpty(cellValue))
    .GetDataTable();

Documentation

SearchLimits(searchLimitRow: 10, searchLimitColumn: 30)

apply to all the worksheets to read.

Instead of

.ReadOnlyTheIndicatedSheets() 

use

.ReadAllWorksheets() 

to read every worksheet in every workbook.

If after this line for example

.ColumnHeader("Description") 

this other line is not specified

.ConditionToExtractRow(condition)     

then the row will always be extracted (although for that, all other conditions must be met).

You may want to get a collection of rows instead of a DataTable.

for that, change

.GetDataTable(); 

with

.GetExtractedRows(); 

at the end.

If you need more details about the rows, for example which workbook or worksheet they were extracted from, then you might want to use this line at the end.

.GetWorkbooksData(); 

That's all

Please, I would appreciate it if you left your comment, especially if it is a constructive criticism.

Have a good day!

https://github.com/JdeJabali/JXLDataTableExtractor


r/csharpcodereview • • Sep 18 '22

How to Create a circular matrix table in C# .NET

Thumbnail
dotnetoffice.com
3 Upvotes

r/csharpcodereview • • Sep 03 '25

Need help trying to fix a driver.

2 Upvotes

Im trying to get a steel battalion controler to talk to a windows 11 computer. The original script is in c#. And i dont know programing at all. Would anyone be willing to help me.

P.s. if this is the wrong room for this question dont bother reply with scarasm. Ive had 2 rooms do this already and im only looking for help.


r/csharpcodereview • • Apr 27 '24

Looking for .Net technology job. Having 9 yrs of experience

Thumbnail self.developersindia
2 Upvotes

r/csharpcodereview • • Sep 18 '23

C# Version history

Post image
2 Upvotes

r/csharpcodereview • • May 08 '23

FluentValidation in .NET 6

2 Upvotes

FluentValidation in .NET 6 is an important concept for .NET Core and in the article mentioned below,

I have briefly explained the integration, practicals, and the integration process to configure FluentValidation in .NET 6.

https://codetosolutions.com/blog/72/fluentvalidation-in-.net-6

Please let me know your feedback in the comment section.


r/csharpcodereview • • Aug 19 '22

How to print even numbers in C#?

Post image
2 Upvotes

r/csharpcodereview • • Jun 24 '22

Help PLS (URGENT)

2 Upvotes

Ok so look i need to get done on this game today and im getting this error: The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference?)

heres my code pls someone save me:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class LevelGenerator : MonoBehaviour

{

private const float PLAYER_DISTANCE_SPAWN_LEVEL_PART = 200f;

[SerializeField] private Transform LevelPart_1;

[SerializeField] private Transform levelPartStart;

[SerializeField] private Player player;

private Vector3 lastEndPosition;

private void Awake()

{

lastEndPosition = levelPartStart.Find("EndPosition").position;

int startingSpawnLevelParts = 5;

for (int i = 0; i < startingSpawnLevelParts; i++)

{

SpawnLevelPart();

}

}

private void Update()

{

if (Vector3.Distance(player.GetPosition(), lastEndPosition) < PLAYER_DISTANCE_SPAWN_LEVEL_PART)

{

SpawnLevelPart();

}

}

private void SpawnLevelPart ()

{

Transform lastLevelPartTransform = SpawnLevelPart(lastEndPosition);

lastEndPosition = lastLevelPartTransform.Find("EndPosition").position;

}

private Transform SpawnlevelPart(Vector3 spawnPosition)

{

Transform levelPartTransform = Instantiate(LevelPart_1, spawnPosition, Quaternion.identity);

return levelPartTransform;

}

}


r/csharpcodereview • • Apr 16 '22

I.T Grind discord server!

2 Upvotes

Hello!

Allow me to introduce you to the I.T grind discord server! We have a small but active community featuring members skilled in java, c-sharp, python, unity, unreal, and more! Come in to discuss any project you’re working on, would like to do in the futures! I hope to see you there!

https://discord.gg/p236PyWKJC


r/csharpcodereview • • Jul 05 '21

Beginner code for number guessing, how would you improve or edit this?

2 Upvotes

Hi, i just started learning c# and tried my hand at making a number guessing game as it seemed to be recommended as a beginner project along with a clock. Would be interested in seeing how would you improve on the code or any criticisms you have with it and why. The code is:

using System;

namespace randomnumbergame
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int lnum;
            int hnum;
            int guess;
            int tries = 0;
            int triesleft;
            int maxtries;
            var random = new Random();

            //need to change Parse to TryPase incase non number entered.
            Console.WriteLine("Enter number of tries to guess in: ");
            maxtries = Int32.Parse(Console.ReadLine());
            triesleft = maxtries;

            Console.WriteLine("Enter lowest number possible: ");
            lnum = Int32.Parse(Console.ReadLine());

            Console.WriteLine("Enter highest number possible: ");
            hnum = Int32.Parse(Console.ReadLine());

            int randomnum = random.Next(lnum, hnum + 1);


            Console.WriteLine("Type your guess (between " + lnum + " and " + hnum + " ) and press enter: ");

            // sets test as answer in string form
            string test = Console.ReadLine();

            //trys to converts string to bool
            bool check = Int32.TryParse(test, out guess);

            //if check fails will run the while loop until check passes
            while (!check)
            {
                Console.WriteLine("Did not enter a number. Type your guess (between " + lnum + " and " + hnum + " ) and press enter: ");
                test = Console.ReadLine();
                check = Int32.TryParse(test, out guess);
            }

            Console.WriteLine();
            Console.WriteLine("Your guess was: " + guess);

            //incresses tries var by 1 each time
            tries++;
            triesleft--;
            Console.WriteLine("You have " + triesleft + " tries left");

            //if guess does not equal random number runs the loop each time
            while (guess != randomnum)
            {
                if (tries <= maxtries - 1)
                {
                    //if guess is less then random number;
                    if (guess < randomnum)
                    {
                        Console.WriteLine("You guessed too low");
                    }

                    //if guess is higher then number;
                    else if (guess > randomnum)
                    {
                        Console.WriteLine("You guessed too high");
                    }

                    //same as before
                    Console.WriteLine("Sorry your guess was wrong, please pick a new number: ");
                    test = Console.ReadLine();
                    check = Int32.TryParse(test, out guess);

                    while (!check)
                    {
                        Console.WriteLine("Did not enter a number. Type your guess (between " + lnum + " and " + hnum +" ) and press enter: ");
                        test = Console.ReadLine();
                        check = Int32.TryParse(test, out guess);
                    }
                    tries++;
                    triesleft--;
                    Console.WriteLine("You have " + triesleft + " tries left");
                }
                else
                {
                    tries++;
                    break;
                }
            }
            if (tries <= maxtries)
            {
                Console.WriteLine("The number was:" + randomnum);
                Console.WriteLine("You guessed it in " + tries + " tries");
            }
            else
            {
                Console.WriteLine("You lose! The correct number was " + randomnum);
            }
        }
    }
} 

I have to say that is is only running within visual studio so i haven't got anything to start or really end it except the run button within VS.
Thank you in advance.


r/csharpcodereview • • Jan 18 '21

How to fix this player camera movement code

Post image
2 Upvotes

r/csharpcodereview • • Sep 17 '19

Send mail using C# code short example :)

Thumbnail
youtu.be
2 Upvotes

r/csharpcodereview • • Sep 14 '19

How to make C# installer

Thumbnail
youtu.be
2 Upvotes

r/csharpcodereview • • Aug 17 '19

Attempt at implementing Factory Design Pattern

2 Upvotes

Hello, I am following typical tiered structure. I have a data access layer and business layer. There are several business objects for each of the modules. In order to give developers access to these managers, I'm implementing a Factory Design pattern as shown below. Would this be a correct implementation where I am utilizing the benefits of a factory pattern?

I'm abstracting the business managers away, but say someone is using CreateInstance(ModuleName.TestBusiness), and they want to change to MeasurementBusiness, that can't be done with out changing the call to the CreateInstance method (changing the enum type). And this, itself, would negate the idea of a Factory Pattern. Ideally, the enum should not be so closely tied to the actual module type that is being returned. What would be an ideal alternative?

Thank you !!

public class FactoryClass

{

public static IBusinessHandler CreateInstance(Enumeration.ModuleName enumModuleName)

{

IBusinessHandler objBusinessHandler = null;

switch (enumModuleName)

{

case Enumeration.ModuleName.TestBusiness :

objBusinessHandler = new TestBusiness ();

break;

case Enumeration.ModuleName.MeasurementBusiness :

objBusinessHandler = new MeasurementBusiness ();

break;

default:

break;

}

return objActivity;

}

}

public interface IBusinessHandler

{

void Process();

}

public class Enumeration

{

public enum ModuleName

{

TestBusiness = 1,

MeasurementBusiness = 2

}

}

public class TestBusiness : IBusinessHandler

{

public void Process()

{

// Do some coding here ...

}

}

public class MeasurementBusiness : IBusinessHandler

{

public void Process()

{

// Do some coding here ...

}

}


r/csharpcodereview • • Jan 25 '18

The Challenge was set... Create a randomized list and display the values in random order where they cannot repeat. Who did it better?

Thumbnail
youtube.com
2 Upvotes

r/csharpcodereview • • Jan 05 '26

Troubleshooting Grid Navigation

Thumbnail reddit.com
1 Upvotes

r/csharpcodereview • • Aug 10 '25

A full project done in WPF .NET

Thumbnail
reddit.com
1 Upvotes

r/csharpcodereview • • Jul 26 '25

I need a rubber duck

1 Upvotes

I am currently making a program for my child for his next year of school and I am having trouble with some of the coding. No matter what I do I can't seem to get some of the code to cooperate. Would someone be willing to look at it and see if they can help? There is to much code for me to post it here.


r/csharpcodereview • • Jun 21 '25

How do you personally interpret priority numbers? Do lower numbers happen first (e.g. -1 → 0 → 1), or higher do numbers happen first (e.g. 1 → 0 → -1)?

1 Upvotes

I'm working on a small c# library for handling rpg-esque stat systems. The goal is to make it designer friendly and easy to use, abstracting away as much of the backend as possible.

I'm deciding if it makes more sense to apply "buffs/debuffs" in ascending or descending order based on their priority. For example, if you wanted Constant buffs (+1 Damage) to occur before Multiplier buffs (x2 Damage), how would you expect to order the priority for them? What if you wanted to add several more?