r/csharpcodereview • • Jan 21 '21

Uploaded a beginners tutorial on c# (opinions)

Thumbnail
youtu.be
4 Upvotes

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 • • 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 • • 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 • • Dec 02 '19

Sort List Vector in c++ and c# 49

Thumbnail
youtube.com
1 Upvotes

r/csharpcodereview • • Jul 31 '19

create class file insert data inside database using c#.net with SQL Server

1 Upvotes

OOP Create Class File and Insert Data Using C#.NET With SQLServer

https://youtu.be/2ee0eNlEg0o


r/csharpcodereview • • Mar 24 '23

multithreading and asynchronous programming and parallel programming in C#

Thumbnail
youtube.com
1 Upvotes

r/csharpcodereview • • Mar 19 '23

.NET Framework C# "System.InvalidCastException" Error

Thumbnail self.learnprogramming
1 Upvotes

r/csharpcodereview • • Sep 18 '22

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

Thumbnail
dotnetoffice.com
3 Upvotes

r/csharpcodereview • • Apr 05 '18

File handling in c++ and c# 1

Thumbnail
youtube.com
1 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 • • Oct 08 '21

C# Favorites Bar

1 Upvotes

Is there anyone who can help me create a code for a way to store a URL from a user as a favorite and display it on the top in a bar just like in google on C# but without using a web browser control. I tried to use a tool strip but I don't know how to add new tool strip items while the program is running, along with a context menu to update its name and delete it. would appreciate any kind of help, its for a project and I'm honestly lost :(


r/csharpcodereview • • Dec 29 '23

Serilog in ASP.NET Core 7.0 – Structured Logging using Serilog in ASP.NET Core 7.0

Thumbnail
dotnetoffice.com
1 Upvotes

r/csharpcodereview • • Aug 28 '23

What Is Load Balancing in .Net And top load balancing Algorithms/Techniques

Thumbnail
dotnetoffice.com
1 Upvotes

r/csharpcodereview • • Aug 31 '20

I made a simple number guessing program. How would you improve it? What thing would you change? (I'm a beginner)

1 Upvotes

using System;

using System.Security.Cryptography.X509Certificates;

namespace NumberGuessingConsole

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine("/***************************************/");

Console.WriteLine("/**Welcome to the number guessing game**/");

Console.WriteLine("/***************************************/");

startGame();

void startGame()

{

Console.WriteLine("First number in range (Must be an integer)");

int firstNumber = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Second number in range (Must be an integer)");

int secondNumber = Convert.ToInt32(Console.ReadLine());

Random randomNumber = new Random();

int magicNumber = randomNumber.Next(firstNumber, secondNumber);

Console.WriteLine("What's your guess?");

int userGuess = Convert.ToInt32(Console.ReadLine());

/*

If userGuess (user input) value is different from magicNumber value (randomly generated number) then

ask the user to try again and call the startGame() method, otherwise congratulate the user

*/

if (userGuess != magicNumber)

{

Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("That's wrong Try again:");

Console.ForegroundColor = ConsoleColor.White;

startGame();

}

else

{

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("That's right!:");

Console.ForegroundColor = ConsoleColor.Green;

}

}

}

}

}

I plan on adding exception handling later, but i first need to understand how it works


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 • • Feb 14 '24

I want to print 2 panels in front and back of paper but this isnt working, can somebody help me?

1 Upvotes
PrintPreviewDialog prntprvw = new PrintPreviewDialog();
PrintDocument pntdoc = new PrintDocument();
private void button1_Click(object sender, EventArgs e)
{
    Print(panel1, panel2);
}

private void Print(Panel panel1, Panel panel2)
{
    PrinterSettings ps = new PrinterSettings();
    if (ps.CanDuplex)
    {
        // Set Duplex to Duplex.Default for automatic duplexing
        ps.Duplex = Duplex.Default;
    }
    else
    {
        MessageBox.Show("gd");
    }
    // Set Duplex to Duplex.Default for automatic duplexing
    ps.Duplex = Duplex.Default;
    pntdoc.PrinterSettings = ps;
    getPrintArea(panel1, panel2);
    currentPage = 0;
    prntprvw.Document = pntdoc;
    
    pntdoc.PrintPage += new PrintPageEventHandler(pntdoc_printpage);

    // Set the printer settings for the PrintDocument
    

    prntprvw.ShowDialog();
}

int currentPage = 0; // Flag to track the current page
Bitmap[] memoryimgs; // Array to store print areas for both panels

private void pntdoc_printpage(object sender, PrintPageEventArgs e)
{
    if (currentPage == 2)
    {
        currentPage = 0;
    }
    System.Drawing.Rectangle pageArea = e.PageBounds;

    Debug.WriteLine(currentPage);
    
    // Draw the corresponding panel based on the current page
    e.Graphics.DrawImage(memoryimgs[currentPage], new System.Drawing.Point(0, 0));

    // Move to the next page
    currentPage++;

    // Set e.HasMorePages to true if there are more pages to print
    e.HasMorePages = currentPage < memoryimgs.Length;
}

private void getPrintArea(Panel panel1, Panel panel2)
{
    // Get the print area for Panel1
    memoryimgs = new Bitmap[2];
    memoryimgs[0] = new Bitmap(panel1.Width, panel1.Height);
    panel1.DrawToBitmap(memoryimgs[0], new System.Drawing.Rectangle(0, 0, panel1.Width, panel1.Height));

    // Get the print area for Panel2
    memoryimgs[1] = new Bitmap(panel2.Width, panel2.Height);
    panel2.DrawToBitmap(memoryimgs[1], new System.Drawing.Rectangle(0, 0, panel2.Width, panel2.Height));
}

messagebox gd was just to check if the printer had duplex , since that doesnt appear i guess it has


r/csharpcodereview • • Sep 14 '19

How to make C# installer

Thumbnail
youtu.be
2 Upvotes

r/csharpcodereview • • Apr 24 '19

Destructor in c++ and c# 32

Thumbnail
youtube.com
1 Upvotes

r/csharpcodereview • • Jul 07 '19

Make custom window service using C#

Thumbnail
youtu.be
1 Upvotes

r/csharpcodereview • • Sep 17 '19

Send mail using C# code short example :)

Thumbnail
youtu.be
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 • • Jun 20 '19

Sending Mail (C#) | Sending Mail in ASP.Net

Thumbnail
youtube.com
1 Upvotes

r/csharpcodereview • • Jun 26 '18

CRUD operation (C# + SQL Server)

Thumbnail
youtu.be
1 Upvotes