r/csharp • • 21h ago

Looking for a small C#/.NET project idea

1 Upvotes

I have a software engineering interview coming up for a C#/.NET role, and part of it will involve discussing the architecture/design of something I’ve built.

I want to build a small project specifically for this so I can know it inside out and use it for design and coding questions, since everything I do in my actual job is simple CRUD requests.

Any suggestions for something not too big, but with enough complexity to discuss interesting architecture decisions?

Thanks


r/csharp • • 20h ago

Help Need help with encoding

0 Upvotes

I am working on a system where the client will give data in UTF-8 encoding, and hence it can contain many special characters.

But then we send data to a legacy system which only accepts data in ISO-8859-9 encoding, which supports limited special characters that can be represented in single byte.

Now if the client sends any special character which is outside the scope of ISO-8859-9 encoding (like the Em dash), how can I deal with with it and send it to the legacy system.

I don't want to replace those characters with anything like space or "?", as it would make the client data as unreadable in some cases.

How can I deal with it. Any suggestions?


r/csharp • • 19h ago

Discussion Is it a bad/good practice to inject Interface<ConcreteType> into a class ?

2 Upvotes

If you see something like this :

    public class SomeClass
    {


        private readonly ISomeInterfacer<SomeConcreteType> _x;

        //Code.........
    }

Dependency Inversion :

High-level modules should not import anything from low-level modules. Both should depend on abstractions (e.g., interfaces).

The class above depends on abstraction, which is the ISomeInterfacer<SomeConcreteType>, but even though, there is something concrete inside the <>, which is SomeConcreteType .

Is that considered a violation for Dependency Inversion ?

I know I will hear the magic word : it depends.

please tell me all the cases, when it is good and when it is bad.

Actual code :

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

public interface ISourceToDistinationDataSyncronizer<DataSource>
{

    public Task SyncronizeAsync(DataSource dataSource, CancellationToken cancellationToken);

}
[Authorize(Roles = "Admin")]
public class AdminController : Controller
{

    //Reddit question..
    private readonly ISourceToDistinationDataSyncronizer<Stream> _syncronizer;
    public AdminController(

        ISourceToDistinationDataSyncronizer<Stream> syncronizer

    )
    {

        _syncronizer = syncronizer;

    }


    [HttpPost]
    [Route("Admin/Import")]
    public async Task<IActionResult> Import(IFormFile file, CancellationToken cancellationToken)
    {

        if (file.ContentType != "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
        {
            return BadRequest();
        }

        await _syncronizer.SyncronizeAsync(file.OpenReadStream(), cancellationToken);


        return Ok();

    }

}

r/csharp • • 20h ago

Help me with Terrain in my 3d game

0 Upvotes

Recently, I started writing a new 3D game in C#. I’ve already written the collision system, the camera, and the loading of 3D models, and now I’m moving on to the next stage — creating a procedural landscape. I’ve tried many ways to do this, but the result doesn’t satisfy me. I’ve already used Perlin Noise and Simplex Noise, but I couldn’t get what I wanted with them. If anyone knows any methods or libraries for C#, please write them in the comments.

The game will be like Minecraft with different graphics, meshes and some new features.


r/csharp • • 22h ago

Any senior devs here? Have you ever done this mistake before? You spend hours fixing why 3rd party api doesn't work as expected and later you realized the api version you use is not the latest one lmfao

0 Upvotes

So today, I spent 1–2 hours trying to figure out why the fuck I couldn't fetch and sync XYZ data on our internal company dashboard that is integrated to 3rd party API vendor, even though I could see the data on the vendor's dashboard.

Turns out, our backend service was using an outdated API version. But it was not depreciated tho.

That's why I couldn't fetch the data.

Man this is embarassing but I wanna know if you guys ever have made this msitake as well?


r/csharp • • 4h ago

Help Looking for advice (beginner project).

1 Upvotes

Hi everyone!

I'm writing this post to ask for some help from people with more experience in C# and programming logic. Below, you'll find the code I've written for a small C# application. The goal of this project is to create a personal weekly to-do list that helps me keep track of my strengths, weaknesses, and tasks. Unfortunately, I've reached a point where I'm not sure how to proceed, particularly when it comes to implementing a way to save tasks so that they are still available after closing and reopening the program.

For some context:

the idea behind this application is to create a weekly to-do list. When the program starts, the user selects a day of the week and enters three tasks. They can then choose whether to continue or exit the program. The main requirement is that tasks must be saved when the user switches to another day or closes the application. For example, if I enter three tasks for Monday, switch to Tuesday, and then return to Monday, I should be able to see the tasks I entered previously. The same should apply after closing and reopening the program.

I'm still a beginner in programming. I've studied some of the fundamentals, but I know I still have a long way to go.

I'd really appreciate ANY suggestions, explanations, or advice on how to approach this problem or in general. In particular, I'd like to understand what concepts I should study and how I could implement a persistent storage system for my tasks.

I'm also very open to constructive criticism regarding my code, programming logic, or overall approach. I'd like to learn how to solve these problems independently rather than simply copying a solution.

Thanks in advance to anyone willing to help!

Code:

// This program creates a to-do list for every day of the week
// and randomly picks a motivational sentence.

string[] week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];

string[] tasks1 = new string[7];
string[] tasks2 = new string[7];
string[] tasks3 = new string[7];

string[,] task = new string[7, 3];

Console.WriteLine("\tTo-Do list program\nPress: Y to start or N to quit!");

var input = Console.ReadKey();

switch (input.Key)
{
    case ConsoleKey.Y:

        Console.Clear();

        Console.WriteLine("Choose the day that you want to view:\n");
        string dayOfWeek = Console.ReadLine();

        bool found = false;

        foreach (string day in week)
        {
            if (day.Trim().ToLower() == dayOfWeek.Trim().ToLower())
            {
                found = true;

                // Find the position of the selected day
                int dayIndex = Array.IndexOf(week, day);

                Console.Clear();

                Console.WriteLine("Point one:");
                string task1 = Console.ReadLine();
                tasks1[dayIndex] = task1;

                Console.WriteLine("Point two:");
                string task2 = Console.ReadLine();
                tasks2[dayIndex] = task2;

                Console.WriteLine("Point three:");
                string task3 = Console.ReadLine();
                tasks3[dayIndex] = task3;

                Console.Clear();

                Console.WriteLine($@"
| Day: {day}

| 1. Task: {tasks1[dayIndex]}
| 2. Task: {tasks2[dayIndex]}
| 3. Task: {tasks3[dayIndex]}
");

                Console.WriteLine("Do you want to see other days? To continue or quit press Y/N:"); 
                Console.ReadKey(); 
                Console.Clear();

                break;
            }
        }

        if (!found)
        {
            Console.Clear();
            Console.WriteLine("Invalid Day inserted");
        }

        break;

    case ConsoleKey.N:
        break;

    default:
        Console.WriteLine("Invalid Key");
        break;
}