C#

C

C#

We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.

Join

Data structure options for UI virtualization

I'm trying to find a good data structure for UI virtualization of collection controls to keep track of each control's estimated dimensions. Virtualization is (eg.) when you have a million data rows and only 10 can fit on screen, so you only create 10 controls. As the user scrolls, controls that move offscreen are recycled (returned to pool) and rows that now appear onscreen are materialized as controls. Because only on-screen controls exist, I cannot store row-specific metadata on them to later retrieve because they get wiped during recycling. The main problem I'm trying to solve is obtaining the total height of all rows when row heights can vary: combining actual measurements from rows that have been previously materialized and estimated heights for ones that haven't. While I could store row height information in a standard array, typical insert and delete operations will result in large move operations....

it doesnt let me insert a code into my sprite :c

So i tried to inster a script into my sprite but it doesnt work and it shows a error
No description

Need help selecting objects in a list

This code is simply a testing file so I can figure out how to make this work. In this file I created the class Hero with three int values id, lvl, hp. A friend explained how to set this up so that I can create objects via this class. I'm not sure why the int's need to be declared three times or what the 'this' statement does or why it is needed, an explanation on this would be nice but not necessary at the moment. What I'd like to do in this file is allow the user to pick a Hero. line 29 creates the Hero list, line 30 and 31 allow user input. 33 and 34 are objects, the test Hero's named dee and goo. Lines 37 and 47 are my various attempts at getting trying to get the listing to appear and for me and to be able to select something in the list but unfortunately the foreach and for don't work, I tried LinqQuery but I'm not even sure how that works. On lines 57 to 61 you can see testing on object manipulation but unfortunately it's hard coded to the first Hero 'dee'. I don't know what I would type in instead to allow for a more generic object value changes depending on which Hero was selected....
No description

trying to fix a bug where i cant get the click event on a buttom

hello, i have an issue with a windows form program, i have a panel where buttons gonna be placed, and i have a TableLayoutPanel that component gonna be the layout to the buttons "styles" i mean ``` buttonLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 70F)); // 70% for the image buttonLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 30F)); // 30% for the text...

Trying to create an Image in Visual Studio 2022

I wrote this code to create an image (technically I created the image by using the Toolbox's XAML Controls) And I added the source tag and directed it to assets. But for some reason it doesn't render the image, as its just invisible. I also cant move the image element anymore.
No description

✅ Folder Structure

Let's say I want to create ASP.NET Core app and publish it on GitHub. I think it would be wise to create two parts: 1) the app itself, 2) tests (let's say it would be xunit). What folder structure you would propose in such a case?...

✅ how do i publish my .NET project?

so i made this chess thingy (do check it out, i spent a month on it) and I want to publish it online so i can primarily use it in my other projects. how exactly do i go about this? i'm using vscode btw - vs runs like shit and doesn't correct my code properly. command line would be preferred....

Advice about file management in projects

Recently I have started trying to make my code cleaner and I started thinking about the structure of my project. I read and was following the rule that each class should be in a separate file. I applied it to interfaces, abstract classes. But what about enums, structs? They are mostly always not very big. May someone advise me an article or a book where I can read how project files should be managed please. Also, I would like to know more about the right way of splitting project files into diffe...

i cant run my code and i dont know what to do

exactly as i stated, i dont know im new to c# and it worked in class but doesnt work in home, thanks for help
No description

How to handle account registrations with Firebase and ASP.NET Identity

So im currently building a large scale project and had a question about Authentication with Firebase while using ASP.NET Identity Someone on here already gave me a code snippet that configures my Authentication to use Firebase to check the session, but now I have a question about how i would handle user registrations and logins to for example create a login history entry or simply create a user in my database...

how to use wirteLine in monogame

Im trying to gifure out how i can display a score directly on the screen using writeLine but it dosent seem to work

Starter pack for the perfect project

I work as a backend developer myself, but I'm actively moving towards full stack. And I still don't fully understand which practices are worth applying, and where they may be superfluous. I would like to know how to distinguish between situations when certain approaches are really needed and when it is better to avoid them. In my work, I use quite classical approaches, such as Clean Architecture, where the project is divided into several layers. I also use Repository and Unit of Work patterns to work with data. Additionally, I implement caching, logging and write a global error handler in the form of middleware. Sometimes I use FluentValidation to validate data....

Lucene: best analyzer for handling PascalCase?

I need to make an index that has a field which contains PascalCase strings, and users of the index are also expected to search for them in PascalCase. What is the best analyzer to handle that?

created a new view but that view only outputs the html (of the login page!)

I am pretty sure I have been missing out something very trivial, so I appreciate another set of eyes again. Context: I made a new view (JumpToDashboard) on my simple ASP.NET core app in addition to the default Index and Privacy views. Whenever the browser runs the app and accesses to the JumpToDashboard page it only turns to the whole html of the login page (as per screenshot- I already found this embarassing). It was supposed to display a view with the title dashboard. ...
No description

C# Codeforces Template

I'm looking for a C# template for the codeforces contest. If anyone has or wants to suggest me please share your template with me. I'm planning to participate in a contest using c#. So, please help me....

CS0051: Inconsistent access

Hello, im currently working on an aircraft Database to store all my photos. Today I wanted to implement an USC for all the airlines. Everytime I set create a new airline I want it to create a new USC with a new airline, kinda like pokemom cards, but in the USC class it says following error: CS0051 Inconsistent access: Parameter type "MySQL.AirlineData" is less accessible than method "AirlineField_UC. SetAirlineData(MySQL.AirlineData)" MySQL.cs (Got all SQL querys) public class AirlineData...

✅ Factory Method Pattern

Does someone have a good explanation or perhaps a link to somewhere where i can learn this? Been trying to find a video or similar but it just doesn't stick :(

✅ SQL code

"Create a procedure that receives a value in the variable, 'NoDays' (int), to check how many days there are between the order date and shipment and to See which freighters have been used. Where shipping has begun less than 2 weeks within RequiredDate. Run the procedure and search for the ships where the time between the order date and the...
No description

How can I get service provider from service collection?

Hello, everyone. am working on console app using meditR, want to get service provider from service collection. I've got a compile error on ServiceCollection.BuildServiceProvider
IServiceCollection' does not contain a definition for 'BuildServiceProvider' and no accessible extension method 'BuildServiceProvider' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?
IServiceCollection' does not contain a definition for 'BuildServiceProvider' and no accessible extension method 'BuildServiceProvider' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?
...
No description

Why do my Admin controllers trigger OnRemoteFailure in ConfigureOpenIdConnectOptions when using cust

Why do my Admin controllers trigger OnRemoteFailure in ConfigureOpenIdConnectOptions when using custom authentication policies? I am configuring authentication and authorization in an ASP.NET Core application using both OpenIdConnect and Microsoft Identity. The goal is to make the frontend controllers for my site use the OpenIdConnect (IdentityServer4) and the admin controllers use AzureAd. Here's a summary of my setup: In Startup.cs, I have configured authentication and authorization as follows:...