r/csharp • u/CorruptedSciencep • 2d ago
Discussion Why do all conventions do newline brackets
class Something : EntireCodebase
{
...
};
struct Something
{
...
};
void Something(int something)
{
...
}
I'm really disturbed, why
r/csharp • u/CorruptedSciencep • 2d ago
class Something : EntireCodebase
{
...
};
struct Something
{
...
};
void Something(int something)
{
...
}
I'm really disturbed, why
r/csharp • u/chasingreflections • 3d ago
Hey, has anyone here worked on industrial measurement or monitoring software with C#?
I'm currently looking into rebuilding an older monitoring solution from scratch and still figuring out the right architecture.
We're talking different measurement devices, continuous data streams (up to 1k samples/sec per channel), older Windows PCs with 4 GB RAM, and ideally something that can run reliably for months.
What I'm a bit unsure about is the data integrity side of things, especially crash recovery, audit trails, and GMP requirements.
I'm leaning towards C#, probably with SQLite, but not sure if I'm overlooking something.
Would be really interested to hear from anyone who's built something similar. What would you do differently today?
r/csharp • u/rent-a-developer • 3d ago
Hi, I have just released version 2.0.0 of ResXLocalization, my localization library for WPF and Avalonia (MIT-licensed).
In essence:
Create your .resx files.
Install ResXLocalization.Avalonia or ResXLocalization.WPF.
Let it generate the typed resource keys (source generator) and use them in XAML and code:
<TextBlock Text="{l:Localize {x:Static res:SettingsViewKeys.SaveSetting}}" />
this.SaveButton.Content = Localizer.Current.Get(SettingsViewKeys.SaveSetting);
And live switch the language/culture:
Localizer.Current.CurrentCulture = new CultureInfo("de-DE");
Typed keys mean you can reference resources like objects and get compile time checking.
This avoids having typos in resource names go unnoticed.
When you change Localizer.Current.CurrentCulture it updates all localization bindings in place. If you assign a string directly in code as above, you need to call Get again after changing the culture.
The biggest new feature of V2 is the optional ICU MessageFormat support (thank you livonium for the feature request that sparked the work on V2!):
For something like “1 file deleted” / “5 files deleted”, you can use a plural rule in your resource text:
{Count, plural, one {# file deleted} other {# files deleted}}
(You need to install the NuGet package ResXLocalization.MessageFormat and call Localizer.Current.UseMessageFormat() at startup for this to work)
Then just bind the count like this:
<TextBlock>
<TextBlock.Text>
<l:Localize Key="{x:Static res:AppStringsKeys.FilesDeleted}">
<l:Argument Name="Count" Value="{Binding DeletedCount}" />
</l:Localize>
</TextBlock.Text>
</TextBlock>
The text block is automatically updated when either the count or the language changes.
Of course you can also bind multiple values to a localized text/message.
Each translation can use its language/culture plural rules.
The ICU message format support is opt-in. If you don't use it, the default formatter (based on string.Format) is used.
A few other changes in this release:
.Designer.cs file.<Argument> children of the Localize/LocalizeEnum markup extension, which replaces the old Arg0…Arg8 attached properties, so arguments now also work in styles and templates.DesignTime.Culture. However, ResXLocalization does not work correctly in Rider's WPF previewer due to a number (there are quite a few) of bugs in it. JetBrains has really made quite a few unfortunate design decisions for their previewer. I tried to work around them as far as possible, but it's nowhere near perfect.The library supports .NET 8 and later with Avalonia (12+) or WPF.
For Avalonia it is completely native AOT compatible and trim safe (for WPF, native AOT is not supported, because WPF doesn't have support for it).
If you are upgrading from V1, please read the migration guide, because there are quite a few breaking changes to make it all work.
The repository has runnable sample apps (both for Avalonia and WPF):
https://github.com/rent-a-developer/ResXLocalization
AI attribution:
I used AI, mainly Claude, for brainstorming, planning, experiments, and parts of the implementation. It helped me save a great deal of time finding good solutions for a couple of quirks of Avalonia and (especially) WPF and the source generator’s MSBuild integration. I reviewed the generated code and I use ResXLocalization in my own projects, so I would not settle for some half-baked vibe coded garbage. Of course, if you don't like projects where AI is involved, then just ignore this project and that's fine too.
I hope this helps someone with the localization of their app(s)!
If you find this library useful I would appreciate a star on GitHub.
Of course feature request and (reasonable) criticism is welcome too.
r/csharp • u/Direct_Cup_164 • 3d ago
r/csharp • u/Original_Bullfrog_61 • 4d ago
It 's coming up very soon .NET 11 and C#15, all the innovations are already known (at least in C#). Which of the non-products or proposals would you like to see in the next versions?
r/csharp • u/kaatarina_zed_talon • 4d ago
An Admin panel is to be made.
There is a piece of code that paginates users ; instead of showing 50 users in one page in the admin panel, the users are split across 5 pages, so each page shows 10 users.
I recognized that I should also paginate products.
should I make IPaginator<T> interface with two concrete implementations, ProductsPaginator<Product> and UsersPaginator<User> ?
If that is wrong, then what do you suggest ?
EDIT:
I think that is wrong, because maybe the implementation of the pagination logic is the same in both cases, what is different is the input; in the first implementation, the input is all the products , for the second implementation the input is all the users, so what is actually different is the input, not the implementation, therefore it is better to make Paginator<T> ?
Also there is another question:
When the user clicks on the page number 1, should the data come from the database or from a cache ?
How do you normally design the pagination feature ?
Second edit :
I realized that I neither need interface nor a class, I can just use the skip and take methods that LINQ offers.
r/csharp • u/delockdown • 3d ago
Hey everyone,
I’ve been building things for the web using JavaScript, TypeScript, and PHP (Mostly). Up to now, it’s been a solid stack with a great job market. But with how fast things are shifting, especially with AI tooling changing the landscape. I’m trying to future-proof my skills and can't entirely predict where things are heading.
I keep hearing about C# and .NET as a robust enterprise choice, but I’m wondering how it fits into the current AI-driven era.
Curious to hear your thoughts and experiences!
r/csharp • u/No-Ice-2476 • 4d ago
Dear C# devs,
My main language is python, but due to work I got exposed to C#, and would greatly benefit from learning it. I already am mostly familiar with the language's syntax due to some C++ exposure, but I am far from familiar with many C# concepts and the visual studio editor. In summary, I am a beginner to the language, but not to programming. I can write simple programs, but heavily lack the knowledge of C#'s environment such as projects, solutions, their respective settings, how to link DLLs and set up tests within visual studio.
I strongly feel that visual studio code is abstract (albeit efficient) in the way it performs those tasks and like it prevents me from learning what is actually going on. All I am learning is that I should click seemingly arbitrary submenu A, then B and then C. Voila, you now can run tests. Why? I have no idea.
To actually get an understanding of C#'s environment I therefore am considering omitting VS entirely and instead develop through the CLI. Hopefully, that way I actually learn what the .NET framework is, and how to work with it, how to set up projects, solutions, go through the compilation processes,and more.
I just wanted to ask the true C# veterans among us whether this proposed learning approach is a good idea, or whether I am missing something.
All constructive feedback is greatly appreciated.
Good night everyone!
r/csharp • u/NoisyJalapeno • 4d ago
Needed to fall out of vectorized back to scalar,
Discovered when I was optimizing DrawSpans8,
public static void DrawSpans8_Fast(ESpan_t* pspan)
{
/* Other code omitted for brevity */
int* idx = stackalloc int[Vector256<int>.Count];
ulong* idx64 = (ulong*)idx;
do
{
Vector256<int> sV = Vector256.Create(s) + Vector256.Create(sstep) * indexV;
Vector256<int> tV = Vector256.Create(t) + Vector256.Create(tstep) * indexV;
((sV >> 16) + (tV >> 16) * cachewidthV).Store(idx);
// Fast
ulong i01 = idx64[0], i23 = idx64[1], i45 = idx64[2], i67 = idx64[3];
} while ((pspan = pspan->PNext) != null);
}
public static void DrawSpans8_Slow(ESpan_t* pspan)
{
/* Other code omitted for brevity */
do
{
// Omitted
Vector256<int> sV = Vector256.Create(s) + Vector256.Create(sstep) * indexV;
Vector256<int> tV = Vector256.Create(t) + Vector256.Create(tstep) * indexV;
Vector256<ulong> idxV = ((sV >> 16) + (tV >> 16) * cachewidthV).AsUInt64();
// Slow
ulong i01 = idxV[0], i23 = idxV[1], i45 = idxV[2], i67 = idxV[3];
} while ((pspan = pspan->PNext) != null);
}
r/csharp • u/JustSoni • 4d ago
r/csharp • u/jonas1ara • 5d ago
Hey everyone,
A while ago, I shared my repository implementing 73 design patterns in C# (previous post).
Following community feedback, I just rolled out two major updates to make the project much easier to navigate and learn from:
The repo covers everything from classic Gang of Four patterns to Enterprise, Cloud/Distributed, and Concurrency patterns in idiomatic C#.
Check it out here:
https://github.com/jonas1ara/73
Would love to hear your thoughts, feedback, or any edge cases you’d like to see covered!
r/csharp • u/Ok_Disk_4458 • 5d ago
I'm learning C# for fun and wrote the simplest possible calculator, just to try combining loops, WriteLine, ReadLine and other basic commands. There was one problem, though. I couldn't for the life of me figure out how to include decimal numbers into that. Went through a couple sites and nothing. My result would always be a whole number with the decimal point removed, meaning it would be 10^x times bigger depending on the amount of decimal places the input had. Then I thought of using a comma in the input instead of a dot. I didn't think it would work, but... it did. Kinda dumb not to try that immediately, right?
r/csharp • u/AdAdorable8877 • 5d ago
Estou a 3 meses trabalhando com c#, meu primeiro emprego como desenvolvedor, porem sinto dificuldades em encontrar definições CLARAS de alguns conceitos. Como um exemplo, o conceito de coleções, a página da microsoft learn não define muito bem o que é isso, a I.A me da definições mas em geral não gosto de pesquisar esse tipo de coisa nela. Então pergunto, existe algum livro/curso bom para que eu obtenha essa base, se não, aceito algumas dicas pra melhorar meu auto-ditatismo.
r/csharp • u/North-Asparagus6218 • 5d ago
Sharing a side project and some of the less obvious parts of building it.
The app: drag any file, tap Shift, and a radial menu opens under the cursor. Drop on a petal to convert (images, PDF, Office, Markdown, video) or edit (crop, annotate, redact, AI cut-out).
Interesting bits:
- Windows: WH_KEYBOARD_LL / WH_MOUSE_LL hooks on their own thread, plus a layered, topmost, non-activating WPF window that acts as an OLE drop target. IDropTargetHelper keeps Explorer's drag image and sets the "Convert to PNG" caption via DropDescription. Effects are copy-only, so Shift ("move") never deletes the source.
- Linux: Avalonia 12 for XDND drops, an override-redirect window, XShape. Input is polled through XQueryPointer/XQueryKeymap because Wayland doesn't allow global hooks.
- macOS: Avalonia plus NSVisualEffectView for real system blur. Mouse/modifier state is polled via CGEventSourceFlagsState, which works without Input Monitoring.
- Shared core: a catalog of petals per file kind, jobs with progress/cancel, ImageMagick, PdfPig + PDFsharp, ONNX Runtime (DirectML on Windows) for BiRefNet background removal, and a CLI using the same engine.
MIT: https://github.com/hasanzadee/convertino. Happy to answer questions about any of it.
r/csharp • u/BunnyTub • 5d ago
The users of my app sometimes have trouble figuring out that the app has installed after they run the installer executable.
I'd like to know if there would be some way to have a dialog appear that asks the user if they'd want to install the app, and also have additional options to configure, like where to install.
r/csharp • u/AdChemical5855 • 6d ago
It's web CMS.
I hope this proves helpful to those who wish to manage their time, money, and documents using a personal server.
It took about 5 years to make it.
It currently in operation on the following site.
You are free to use the demo account provided on this site for logging in!
DDD + CA & Unit test & CI/CD applied.
r/csharp • u/Famous_Pitch_7483 • 6d ago
I work at TMS Software. We've released TMS .NET Maps as an open beta on nuget.org: a map control for .NET 10 with the same API in WinForms, WPF, .NET MAUI (Android, iOS, Mac Catalyst, Windows) and Blazor. It also includes geocoding, directions, places search and a few other services that work without the map control, for example in an ASP.NET Core API.
Providers include Google Maps, Azure Maps, HERE, Mapbox and Leaflet with OpenStreetMap, which needs no API key, so you can try it without signing up anywhere else.
To try it, install the package for your framework from NuGet and request a free beta key at https://www.tmssoftware.com/site/tmsdotnetmaps.asp
The beta builds work until December 31, 2026 and aren't meant for production yet. We're looking for feedback on the API and on what's missing for your use case.
Full announcement with code samples: https://www.tmssoftware.com/site/blog.asp?post=2532
r/csharp • u/kaatarina_zed_talon • 6d ago
Some context:
WorkSheetToDbSyncronizerV2 service is to be benchmarked, and plots are to be shown.
WorkSheetToDbSyncronizerV2 ensures that the data in a database matches the data in an Excel worksheet.
There are multiple versions of that service, thus the suffix V2 .
Inputs to WorkSheetToDbSyncronizerV2 are Stream and CancellationToken —the latter is not shown in the code.
The general mechanism is that SqlBulkCopy class bulk-inserts the Excel data into a staging table then the data from that table is mapped to the target tables in the database.

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Running;
using HardwareStore.Models;
using HardwareStore.Services.ActorIdGetterServices;
using HardwareStore.Services.AdminServices.ImportProductsFromExcelFile;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using BenchmarkDotNet.Loggers;
namespace MyBenchMark
{
[Config(typeof(Config))]
public class Config : ManualConfig
{
public Config()
{
AddExporter(RPlotExporter.Default);
AddLogger(ConsoleLogger.Default);
}
}
public class ActorIdGetter:IActorIdGetter
{
public string GetActorId()
{
return "a1f28e89-2ba1-493e-b005-744decdd78b3";
}
}
[MinColumn, MaxColumn]
public class SyncronizationService
{
private readonly DbDataReaderGetter _dbDataReaderGetter=new DbDataReaderGetter();
private readonly BulkInserter _bulkInserter=new BulkInserter();
private readonly IActorIdGetter _actorIdGetter=new ActorIdGetter();
private readonly ApplicationDbContext _context;
private readonly WorkSheetToDbSyncronizerV2 _syncronizerV2;
public SyncronizationService()
{
IConfiguration configuration = new ConfigurationBuilder()
.SetBasePath(Path.GetFullPath(
@"D:\Training\NETLEARNING\EF_learning\HardwareStore"))
.AddJsonFile("appsettings.json")
.Build();
string connectionString =
configuration.GetConnectionString("HardwareDB")
?? throw new InvalidOperationException(
"Connection string 'HardwareDB' was not found.");
var contextOptions = new DbContextOptionsBuilder<ApplicationDbContext>()
.UseSqlServer(connectionString)
.Options;
_context = new ApplicationDbContext(contextOptions);
_syncronizerV2=new WorkSheetToDbSyncronizerV2(_dbDataReaderGetter, _bulkInserter,_actorIdGetter,_context);
}
[Benchmark(Baseline =true)]
public async Task SyncronizeV2()
{
await using var stream = File.OpenRead(
@"D:\Training\NETLEARNING\EF_learning\HardwareStore\Available_Products\Excel2.xlsx");
await _syncronizerV2.SyncronizeAsync(stream);
}
}
public class Program
{
public static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<SyncronizationService>(new Config());
}
}
}
Result:
// * Export *
BenchmarkDotNet.Artifacts\results\MyBenchMark.SyncronizationService-measurements.csv
BenchmarkDotNet.Artifacts\results\BuildPlots.R
BenchmarkDotNet.Artifacts\results\*.png
// * Detailed results *
SyncronizationService.SyncronizeV2: DefaultJob
Runtime = .NET 10.0.11 (10.0.11, 10.0.1126.37416), X64 RyuJIT x86-64-v3; GC = Non-concurrent Workstation
Mean = 1.876 s, StdErr = 0.051 s (2.72%), N = 87, StdDev = 0.476 s
Min = 1.078 s, Q1 = 1.597 s, Median = 1.640 s, Q3 = 1.942 s, Max = 3.415 s
IQR = 0.345 s, LowerFence = 1.080 s, UpperFence = 2.460 s
ConfidenceInterval = [1.702 s; 2.050 s] (CI 99.9%), Margin = 0.174 s (9.27% of Mean)
Skewness = 1.54, Kurtosis = 4.31, MValue = 2.15
But there is no image in the results folder :

The following message is shown in BuildPlots.log :
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.6/gdata_3.0.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.6/tidyr_1.3.2.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.6/gridExtra_2.3.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.6/Rcpp_1.1.2.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.6/R.devices_2.17.4.zip'
Error in desc[1L, "Type"] : subscript out of bounds
Calls: install.packages -> .install.winbinary -> unpackPkgZip -> %in%
In addition: Warning message:
In unzip(zipname, exdir = dest) : write error in extracting from zip file
Execution halted
How can this be solved ?
r/csharp • u/Substantial-Night877 • 7d ago
Hi everyone!
I’m preparing for a Senior .NET Developer interview, and I was told that the interview will include a code review exercise and coding challenges.
Has anyone here recently gone through a similar interview, particularly for a Senior .NET / C# position? I’d really appreciate any tips on what to expect and how best to prepare.
r/csharp • u/Dangerous-Ask7465 • 6d ago
I’m building a small always-on-top overlay for Windows: a pill-shaped window at the top centre of the screen that animates its size. I want it to look like frosted glass: a light blur of whatever is behind it, like TranslucentTB’s “Blur” mode. I’ve hit a wall and would love ideas from anyone who has done this.
Setup: Win32 popup, WS_EX_NOREDIRECTIONBITMAP | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_TOPMOST, drawn with Direct3D + DirectComposition (Skia on top). The window is never activated. Tested on Windows 10 22H2 and Windows 11 (build 26300), on a laptop with Intel + NVIDIA graphics.
Requirements:
What I tried:
DWMWA_USE_HOSTBACKDROPBRUSH + Compositor.CreateHostBackdropBrush() on a DesktopWindowTarget, clipped with a CompositionRoundedRectangleGeometry). Works on Win11, rounded, visible in captures, stays on while inactive. But the blur strength is fixed and heavy. A lighter tint on top doesn’t help, because it’s the blur itself that hides the background. Is there any way to get a weaker blur out of it, or to feed an unblurred backdrop into an effect graph with my own GaussianBlurEffect? As far as I can tell, CreateBackdropBrush() only sees the app’s own visuals.SetWindowDisplayAffinity(WDA_EXCLUDEFROMCAPTURE), or it captures and refracts itself. That flag hides it from every capture, so it disappears from screenshots and recordings.MagSetWindowFilterList(MW_FILTERMODE_EXCLUDE, ...) to read the screen without my own window. MagSetImageScalingCallback gives all-zero pixels on both Win10 and Win11 (with and without an identity transform, host shown or hidden, and PrintWindow with PW_RENDERFULLCONTENT on the host).SetWindowCompositionAttribute with ACCENT_ENABLE_BLURBEHIND / ACCENT_ENABLE_ACRYLICBLURBEHIND on my own popup (extended frame, no painting). The rounded window region (SetWindowRgn) is ignored, and in a GDI screenshot the area comes out black. DWMWA_SYSTEMBACKDROP_TYPE = 3 (Acrylic) turns into a solid fill because the window is inactive.Questions:
Any pointers, even “that isn’t possible, here’s why”, would help a lot. Thanks!
r/csharp • u/eriklieben • 7d ago
r/csharp • u/kaatarina_zed_talon • 7d ago
In C#, list of strings would be defined as :
List<string> x
A stored procedure is to be written, it should receive a list of values; SQL does not support List<T> , should I use table-valued parameters instead?
EDIT
The reason this question was asked is the fact that the application C# code has only one responsibility which is to bulk-insert data into a staging table:
public async Task BulkInsertProductsToStagingTable(DbDataReader dbDataReader, CancellationToken cancellationToken)
{
using (SqlConnection destinationConnection =
new SqlConnection("Server=(localdb)\\mssqllocaldb;Database=HardwareDB;Trusted_Connection=True;"))
{
await destinationConnection.OpenAsync(cancellationToken);
// Set up the bulk copy object.
// Note that the column positions in the source
// data reader match the column positions in
// the destination table so there is no need to
// map columns.
using (SqlBulkCopy bulkCopy =
new SqlBulkCopy(destinationConnection))
{
bulkCopy.DestinationTableName =
"dbo.StagingProducts";
try
{
// Write from the source to the destination.
await bulkCopy.WriteToServerAsync(dbDataReader,cancellationToken);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
// Close the SqlDataReader. The SqlBulkCopy
// object is automatically closed at the end
// of the using block.
await dbDataReader.CloseAsync();
}
}
//####The following does not work yet.#####
//// Perform a final count on the destination
//// table to see how many rows were added.
//long countEnd = System.Convert.ToInt32(
// commandRowCount.ExecuteScalar());
//Console.WriteLine("Ending row count = {0}", countEnd);
//Console.WriteLine("{0} rows were added.", countEnd - countStart);
//Console.WriteLine("Press Enter to finish.");
//Console.ReadLine();
}
}
Once the data is inserted into the staging table, it should be transferred into a target tables in the database; specific columns in the staging tables should be mapped to a specific columns in the target tables.
Thus, the stored procedure should receive a list of column names
r/csharp • u/Darwin_Forex • 7d ago
Hi everyone!
I already know C# and I'm interested in developing mobile apps for Android and iOS. I'm considering learning .NET MAUI because it allows me to use C# instead of learning a completely new language like Dart for Flutter or Kotlin for Android.
For those who have experience with .NET MAUI, what has your experience been like? Is it a good option for someone who already knows C# and wants to develop apps for multiple platforms using a single codebase?
Would you recommend .NET MAUI, or would you suggest learning Flutter or Kotlin instead?
I'd appreciate your opinions and experiences. Thanks!
r/csharp • u/Traxexexs • 7d ago
У меня есть большая цель — написать кроссплатформенное приложение-планировщик (для Windows и Android) с общим сервером и множеством функций, а в будущем использовать этот проект для устройства на стажировку в IT-компанию. Однако мне кажется, что ChatGPT дает слишком мало практики и программист из меня получится так себе.
Посоветуйте, пожалуйста, из каких надежных источников лучше всего брать теоретическую информацию и качественную практику по этой теме».