Click here to Skip to main content
15,902,275 members
Everything / Programming Languages / C#

C#

C#

Great Reads

by Wonde Tadesse
The other option will be to use Update Panel ASP.NET control as much as possible. It helps to retain the current position on the page whenever a postback happens to the page.
by Alex Pumpet
A simple program for comparing table data from two sources - SQL databases, Excel, CSV or XML-files
by Dr. WPF
.NET 3.5 SP1 is here! It's time to break out your DirectX skills. This article provides the information necessary to get started using a new DirectX interop feature in WPF called D3DImage.
by John Atten
OWIN, Katana and Middleware Pipeline in ASP.NET

Latest Articles

by Sbk123
This is exciting Pongs game written in C#/ WPF using Visual Studio 2022
by Jo_vb.net
An overview how to use RowDetails, Grouping and Filter for a DataGrid.
by Jens Eckervogt
SByte*/Byte* and SByte**/Byte** Conversion
by Jo_vb.net
This article and the demo are about getting started using the MVVM Community Toolkit and some self-created interfaces / services for Message Box and some Dialogs.

All Articles

Sort by Updated

C# 

U 20 May 2024 by Sbk123
This is exciting Pongs game written in C#/ WPF using Visual Studio 2022
U 20 May 2024 by Jo_vb.net
An overview how to use RowDetails, Grouping and Filter for a DataGrid.
N 20 May 2024 by Sleiman Fady
item.V_DriversVM is probably null, check it using if inline statement, and if there is no data, so display watever you want, else then display the name. Try: @foreach (var item in Model) { @Html.DisplayFor(modelItem...
U 20 May 2024 by Jens Eckervogt
SByte*/Byte* and SByte**/Byte** Conversion
N 19 May 2024 by Richard Deeming
Quote: var duties = _context.Duties.Include(i => i.DriverId); The Include method needs the path to the navigation property to include: Eager Loading of Related Data - EF Core | Microsoft Learn[^] You have passed in the path to the foreign...
U 19 May 2024 by Member 10563482
I have (one to many) relation between 2 tables, when im trying to retrieve the value of a column in the 2nd table it throw null exception: item.V_DriversVM.Name = 'item.V_DriversVM.Name' threw an exception of type...
N 19 May 2024 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
N 19 May 2024 by OriginalGriff
That's not where the error is - that's where it shows up! Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null - which means that there is no instance of a class in...
N 19 May 2024 by Pete O'Hanlon
Whenever you see an error telling you that an Object is not set to an instance, in C#, this is telling you that something in your code is unassigned. In other words you have, somewhere in your code, a null reference. We're not going to be able to...
N 19 May 2024 by Gcobani Mkontwana
Hi Team We experience an issue with our barcode printing application, the problem is when we reprint it gives an error message below on this screen shot. When we debug it and notice on try statement is looking for a path and give this error, all...
U 19 May 2024 by Graeme_Grant
For .Net Core, you would use the BackgroundService[^] class. You can read more about it here: Background tasks with hosted services in ASP.NET Core | Microsoft Learn[^]. If you want to see it in action, I have a couple of articles where I use...
N 19 May 2024 by Dave Kreskowiak
A bigger design question should be do these methods have to run while the site is running? For example, database maintenance jobs? If not, don't even put them into the website code. Write another app, like a Windows Service, that does the...
N 19 May 2024 by RuSho123
Hi, In C# in .NET Core Web App, I want to trigger a method to execute after a specific amount of time (seconds / minutes). I need to "schedule" a large number of such methods executions (500-1000). For example, below: DoProcess(1) should...
U 18 May 2024 by Member 1408653
This works for me int FindFirstVisibleItem(Rectangle rectangle) { foreach (ListViewItem item in Items) { if (item == null) continue; if (rectangle.IntersectsWith(item.Bounds)) { ...
N 17 May 2024 by Eddy Sels 2021
It took me some reading to figure out dictionaries. Thanks for the suggestion, it put me on the right track. Dictionary Soorten = new Dictionary(); string fileContents = LeesJson(); ...
N 17 May 2024 by OriginalGriff
You are going to have to be a lot more specific than that: we have no idea what your project entails, what "automate windows application code" means to you or ... well, anything concrete really. Remember that we can't see your screen, access...
U 17 May 2024 by Meena_16237389
Hi, Please share some techniques to automate Windows(desktop) application in C# to improve the process and ease user to their daily work activity. Below are some way I have found. Please let me the techniques or sample code. What I have...
N 17 May 2024 by Pete O'Hanlon
If what you are asking is how do you add custom controls to the control toolbox, the Visual Studio documentation describes the process of adding custom controls to it. Toolbox window - Visual Studio (Windows) | Microsoft Learn[^]
N 16 May 2024 by M-Badger
If you right click on the toolbox you will see a menu item called Choose Items, click it. In the dialog box that pops up you will see some tabs, go to the relevant tab and click Browse... (bottom right). Choose the assembly containing your...
U 16 May 2024 by Jo_vb.net
This article and the demo are about getting started using the MVVM Community Toolkit and some self-created interfaces / services for Message Box and some Dialogs.
N 16 May 2024 by zzzvvv
answer from chatgpt-4o 1.create new vsix project 2.add your custom control and edit source.extension.vsixmanifest 3.Add a new "Toolbox Controller" class in the VSIX project 4.using Microsoft.VisualStudio.Shell; using...
N 16 May 2024 by Martin Adams 2023
In .NET framework Windows form , I dont want to add certain component to certain project but I want all the custom components to be visible for any newly created app just like the default Microsoft components What I have tried: I want this so...
U 16 May 2024 by Pavel Bashkardin
Management of cryptographic activation keys to protect your application
U 16 May 2024 by Daan Acohen
Learn how to simplify .NET application logging by integrating with Azure Log Analytics and automating the process using GitHub Actions.
N 16 May 2024 by lauxjpn
Your reg-free COM implementation is generally correct and works. The error you are getting is a result from the client app trying to query for the IDispatch interface, which you have not implemented. In .NET (Core), you need to manually...
N 15 May 2024 by Pete O'Hanlon
Would something like this[^] suit your needs?
N 15 May 2024 by Ravi Bhavnani
Get the primary screen's working area and bounds.� If they're the same, the taskbar isn't visible; otherwise it is.� You can use their values to determine the position of the taskbar. Screen.PrimaryScreen.WorkingArea ...
N 15 May 2024 by Member 13762241
Hi, I am looking for solution in .NET core C# with ONVIF, I have solution in WPF for desktop application, but I am looking for the same in .NET Core so that I can see all cameras on browser. Kindly suggest me if any one have solution. Thanks &...
U 15 May 2024 by samtoad
I have an running c# application; when I press the Windows button, the taskbar appears, of which does not affect the program. That's great. But how can I do the following... 1) Detect if the taskbar is present. 2) if so, from where...
N 15 May 2024 by Pete O'Hanlon
We need to challenge some assumptions here. Are you sure that you want to go with the proposed stack? If you are looking for a career, you should be looking at the stack to see if it matches the companies in your area or the ones you would like...
N 15 May 2024 by Richard MacCutchan
There are some excellent tutorials at W3Schools Online Web Tutorials[^] and .NET Book Zero by Charles Petzold[^]. But you can probably find others as well.
N 15 May 2024 by M-Badger
Others may have different ideas, but maybe start by giving your self some basic projects and learn by doing. When you get stuck you can ask more specific questions here. You can do a lot worse than ask ChatGPT for project ideas, pick one that you...
N 15 May 2024 by niksirat2030
Hi everyone, My goal is to learn the C# language for web design. A friend of mine, who has been a programmer for many years, said I should learn the following in order: Front: 1- HTML and CSS 2- Bootstrap 3- JavaScript 4- JQuery Back: 1- C# 2-...
U 15 May 2024 by Yury_Komar
Sure, You can run Apps from WinOS in Android using emulator. I am using "Winlator" from winlator.org Just add a new container, run the container and in start menu install Wine Mono... After that you can run any .NET apps in Android... And it...
N 14 May 2024 by Hasham Ahmad
Wrap your jQuery code inside the $(document).ready() function to ensure it runs after the DOM is fully loaded. $(document).ready(function () { // Handle form submission $("form").submit(function (event) { ...
N 14 May 2024 by Hasham Ahmad
use anonymous types Dim members = entityType.GetType().GetMembers(bindingFlags) _ .Where(Function(m) m.MemberType = MemberTypes.Property OrElse m.MemberType = MemberTypes.Field) _ .Select(Function(m, i) New With { ...
N 14 May 2024 by G_Hosa_Phat
I'm trying to convert a bit of code from C# to VB.NET that's looking for a specific set of class members and I've got it almost completely worked out except for a little Linq query that uses some C# syntax with which I'm unfamiliar: var members...
U 14 May 2024 by Ignatius Baron Rio
This is my Orderform using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using...
N 14 May 2024 by Maciej Los
Sorry, but you're doing it wrong. You should not share controls between forms. You should share data. How? See: Transferring information between two forms, Part 1: Parent to Child[^] Transferring information between two forms, Part 2: Child to...
N 14 May 2024 by Mekadosky
I have a webform application with master page, I want when user initiate any task in the website the loader image will show with modal screen untill the task is finished. below is my master page code.
U 13 May 2024 by M-Badger
AnotherClass { MyClass _myClass {get; set} = new(); } This is a property declaration with an auto-implemented property initialiser. _myClass is a property of type MyClass and it's initialised with a new instance of MyClass when AnotherClass is...
N 13 May 2024 by OriginalGriff
To add to what the others have said, you should expect to get syntax errors every day, probably many times a day while you are coding - we all do regardless of how much experience we have! Sometimes, we misspell a variable, or a keyword;...
N 13 May 2024 by Nick Polyak
In this article I describe how to write C# code that runs in Browser.
N 13 May 2024 by Dave Kreskowiak
Copy and paste the EXACT error message in its entirety. The code you posted doesn't throw the error you're saying it does. It will, however, throw a different error. Since your GetDay method is saying it returns a string, you don't have a return...
N 13 May 2024 by Wendelius
One issue is that you should return a value from GetDay method. Try adding return dayName; to the end of the method
N 13 May 2024 by 0x01AA
With an online c# compiler I get the message: error CS0161: 'Program.GetDay(int)': not all code paths return a value And yes, you forgot the return statement static string GetDay(int dayNum) { string dayName; ... ... return(dayName); }
N 13 May 2024 by sincopleks
class Program { static void Main(string[] args) { Console.WriteLine(GetDay(0)); } static string GetDay(int dayNum) { string dayName; switch (dayNum) { case 0: ...
U 13 May 2024 by AtaChris
Hello, what is the difference between the following ways to instantiate my own class. Case a) AnotherClass { MyClass _myClass {get; set} = new(); } In Case a) I also wonder how I can hand over parameters to the constructor, when they do not...
N 13 May 2024 by OriginalGriff
To add to what the others have said, part of the instantiation process (when you create an instance of a class) is a call to the constructor. When you use new to create a class instance, the system does the following tasks in order: 1) Allocate...
U 13 May 2024 by Dave Kreskowiak
The only way to create an instance of a class is to "new it up". If you're not using new, you're not creating an instance of a class. Case A creates an instance of MyClass and assigns it to the property _myclass of AnotherClass. Since class...
N 12 May 2024 by OriginalGriff
Start by looking for what http 401 error[^] actually means - it's pretty simple! Quote: You may see the “Error code 401” if you try to access an outdated or misspelled URL. It means that the URL is non-existent, and the server may return a server...
N 12 May 2024 by Chinnadurai05
I have a C# project developed using VS2013 and that solution has been deployed in my IIS. Its working fine without any issues. I had updated the solution to make use of VS2017. I have fixed the build issues by adding latest references...
N 12 May 2024 by OriginalGriff
Don't do it like that! 1) Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead. When you...
N 12 May 2024 by lifeofguydonohue
f (string.IsNullOrEmpty(username_txt.Text) || string.IsNullOrEmpty(password_txt.Text)) { MessageBox.Show("Please input Username and Password", "Error"); } else { ...
N 12 May 2024 by OriginalGriff
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here... A very quick search gave loads of results including videos: excel autoincrement numbers and letters - Google Search[^] In...
N 12 May 2024 by OriginalGriff
We can't see your picture, but ... that code doesn't do what you expect it to - the break command in a loop exits the loop immediately. So your code exits the loop during the first time round because it the textbox is empty it executes a break,...
N 11 May 2024 by ras bry
Good day to all, I want to locate all empty TextBox and ComboBox in easy way. As you can see the image below if fields is empty they show message and red back color in which textbox or combobox is empty. image-sample[^] What I have tried: I...
U 11 May 2024 by Higty
C# OpenAI library Assitants, ChatCompletion, FineTuning, ImageGeneration and more
N 11 May 2024 by raddevus
Learn to use SignalR to asynchronously update all web clients in real-time using SignalR broadcasts.
N 11 May 2024 by Zijian
Share Identity Bear Tokens among Distributed ASP.NET Core Web APIs
N 11 May 2024 by Brian C Hart
Discover how to create a user-friendly console application in C# and .NET Framework 4.8, with menu-driven interaction and graceful exit options.
N 10 May 2024 by haseakash
using Timer = System.Windows.Forms.Timer; set this at top of using . Then under class, set Timer timer; DateTime startTime; and then call startTime = DateTime.Now; timer.Start(); to start the timer
U 10 May 2024 by RainHat
You need to shift by 28, not 25. When shifting by hexadecimal digits your shifts will always need to be multiples of 4, as that is the size of a hexadecimal digit. When you shift by 25 bits, you are trying to shift the 2 in the first number...
N 9 May 2024 by Mekadosky
I have a piece of code for login in asp.net C# webform. it uses inbuilt login function, and User.Identity.GetUserId() to catch the userId. But after login the User.Identity.GetUserId() returns null. Below is my login code // Validate the user...
N 9 May 2024 by vickyqu115
A comprehensive guide on identifying issues with the standard WPF DatePicker, exploring its design and interaction intricacies, and introducing a new implementation using a CustomControl named SmartDate.
U 9 May 2024 by Aggeliki Asimakopoulou
I have created a small back end application, in which a main form load runs and all the other forms are child forms. So, I have a form in which I display Orders in a DataGridView depending on users creteria selection dates. When the user chooses...
U 9 May 2024 by Jo_vb.net
Use docking framework, MVVM Toolkit and some features
N 8 May 2024 by Pete O'Hanlon
If SQL Server is shutting down immediately, that means that there is some problem with the installed version. Rather than trying different ways to start it, you should take a look at what SQL Server is telling you is the problem. To figure that...
N 8 May 2024 by Karam Ibrahim
Dear Guys, Hopefully, you are all fine, I have a problem with the starting (( SQL Server (MSSQLSERVER) )) when Windows 11 starts, it stops automatically I tried many ways to solve it. but it is still stopping. I change ( NT Service\MSSQLSERVER...
U 8 May 2024 by Nick Polyak
I demonstrate the samples adding gRPC capabilities to Kestrel ASP.NET server and testing gRPC services with various clients.
U 8 May 2024 by Brian C Hart
This is a guide, written at an intermediate level, to performing high-speed search and replace operations across thousands of files in C# using advanced techniques such as memory-mapped files, asynchronous processing, and user-friendly interfaces with modal progress dialogs.
U 8 May 2024 by Federico Di Marco
Fededim.Extensions.Configuration.Protected is an improved ConfigurationBuilder which allows partial or full encryption of configuration values stored inside any possible ConfigurationSource and fully integrated in the ASP.NET Core architecture using Data Protection API.
N 8 May 2024 by Rob Philpott
Yes, there is. Really settings are outside of presentation, so I'd create a settings class and keep them in there. internal static class Program { [STAThread] static void Main() { ApplicationConfiguration.Initialize();...
N 7 May 2024 by Destiny777
Read a standard Windows Text File character by character
N 7 May 2024 by PeJ Member 14824780
I have a visual studio C# GUI application, where I want to initalize some settings, before loading the gui. At the moment I have a gui with a button, where I "load" the settings. But it does not work, since some of the settings should be done...
N 6 May 2024 by Richard Deeming
Transport Layer Security (TLS) best practices with .NET Framework | Microsoft Learn[^] Rather than trying to "fix" the protocols or ciphers in your code, make sure your code is set to let the OS decide which protocols and ciphers to use. You...
6 May 2024 by Fred Song (Melbourne)
A responsive React frontend interacts in real-time with a .NET 8 Minimal API backend to dynamically display and manage state transitions for a simulated traffic light system.
6 May 2024 by Shao Voon Wong
No frills C++ MP3/WMA DirectShow player class
6 May 2024 by Pete O'Hanlon
Do you have to keep your RootObject? If you change this around, you can use a Dictionary containing the species enumeration as the key, and the bird array as the values.
6 May 2024 by Eddy Sels 2021
these classes were generated by visual studio { public class Rootobject { public Bird[]? Albatros { get; set; } public Bird[]? Avocet { get; set; } public Bird[]? Bustard { get; set; } public Bird[]?...
5 May 2024 by Zijian
Learn to use EventSourceDB through Unit Testing on xUnit.NET
5 May 2024 by OriginalGriff
Assuming this is EmguCV, QueryFrame returns a Mat, and calling ToImage on that returns an EmguCV Image class instance - which is not related to the .NET Image class - so it doesn't support a Bitmap property: Image(TColor, TDepth) Class[^] which...
5 May 2024 by Brijesh C G
using Emgu.CV; using Emgu.CV.Structure; using Emgu.CV.CvEnum; using System.Security.Cryptography; namespace AITest { public partial class Form1 : Form { Image imgInput; private Bitmap img; bool show =...
5 May 2024 by Bharath K A
Multicast DNS (mDNS) is used to perform peer-to-peer discovery of services/devices on a local network
5 May 2024 by 0x01AA
Answered only to remove it from the unanswered list. Solved by OP, see comments to the question!
5 May 2024 by Yahya Mohammed Ammouri
A plugin Copy/Clone existing child records from one Entity to another in Dynamic CRM without doing field mapping.
5 May 2024 by Jo_vb.net
For my last tip/trick I converted/updated a project from MS FW 4.8 to Net 8. I did not care about the version nr but now I plan an update and cannot get vsn 1.1.0.0 How can I set Net 8 file and assembly version number? What I have tried: ...
5 May 2024 by Rinaldo1961
I've created a class for dymo labelprinters using DymoSDK.Implementations; using DymoSDK.Interfaces; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; ...
4 May 2024 by Fercap89
Good morning, I am trying to communicate with an API from windows server 2012 R2, apparently, this operating system takes the ciphers from the Internet Explorer stack, the problem is that in them, there are some with vulnerabilities and the...
4 May 2024 by Dave Kreskowiak
Show the code you're using and the connection string. There are two Access database engines and it sounds like you're using the wrong one. For a .accdb extension, you should be using the Microsoft.ACE.OLEDB.12.0 provider in your connection string.
4 May 2024 by hemal p.shah
Hello, I am trying to connect my windows forms application with access database. But I couldn't. It shows an error' unrecognized database format. I am using microsoft aceess 2007. the database file has .accdb extension. please, help me to solve...
4 May 2024 by vickyqu115
A comprehensive guide on identifying issues with the standard WPF DatePicker, exploring its design and interaction intricacies, and introducing a new implementation using a CustomControl named SmartDate.
3 May 2024 by OriginalGriff
I'd start by looking at Sockets: Socket Class (System.Net.Sockets) | Microsoft Learn[^] Set up a Socket server on the data source PC, and have clients connect to that. When the data changes, the server can update all the clients (or at least...
3 May 2024 by Pete O'Hanlon
This is such a vague question. You want to transfer data between two systems, okay that's fairly simple to do. However, there are questions you have to think about. Does the system you are transferring the data to have the ability to read the...
3 May 2024 by suresh babu lagasani
Hai team I want a code for transfer the data from one system to another through IP address our application has to check the data for ever 5mins what the data is updated that data has to send to another application automatically please help me ...