Click here to Skip to main content
15,892,298 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 Zijian
Learn to use EventSourceDB through Unit Testing on xUnit.NET
by Jo_vb.net
This article and the demo are about getting started using the MVVM Toolkit and some self-created interfaces / services for MessageBox and some dialogs.
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.
by Bharath K A
Multicast DNS (mDNS) is used to perform peer-to-peer discovery of services/devices on a local network

All Articles

Sort by Updated

C# 

N 5 May 2024 by Zijian
Learn to use EventSourceDB through Unit Testing on xUnit.NET
N 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...
N 5 May 2024 by Member 12162161
solution1 and solution3 are the same links.
N 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 =...
U 5 May 2024 by Jo_vb.net
This article and the demo are about getting started using the MVVM Toolkit and some self-created interfaces / services for MessageBox and some dialogs.
U 5 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.
N 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
U 5 May 2024 by Jo_vb.net
Use docking framework, MVVM Toolkit and some features
U 5 May 2024 by Jo_vb.net
An overview how to use RowDetails, Grouping and Filter for a DataGrid.
N 5 May 2024 by 0x01AA
Answered only to remove it from the unanswered list. Solved by OP, see comments to the question!
N 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.
U 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: ...
N 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; ...
U 5 May 2024 by Member 16257679
About code issues in my phone because that not send automatic
U 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...
N 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.
U 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...
N 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.
U 4 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 3 May 2024 by Member 16257130
logout button in html one's we click on button then clear all history and don not go back to privous page
N 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...
N 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...
N 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 ...
N 3 May 2024 by Pete O'Hanlon
The ability to switch a theme is largely going to depend on whether or not you have declared a particular resource as a StaticResource or a DynamicResource. Suppose you have defined a brush colour as a StaticResource. When the application starts...
N 3 May 2024 by Richard Deeming
Quote: [HttpPost] public async Task Create(IFormFile file) [HttpPost] [ValidateAntiForgeryToken] public async Task Create(LeaveRequestCreateVM model) You have two actions which map to POST: LeaveRequests/Create;...
N 3 May 2024 by Christopher Fernandes
I am developing a WPF MVVM-based application using c#. I am trying to create 2 themes light & dark. There will be a button on all windows in either the header or the footer to switch between light & dark themes. I have created a folder hierarchy...
U 2 May 2024 by Gift Sefike
I get this error when i added this code: using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using...
U 2 May 2024 by ras bry
Thank you to all everyone for your support Dave Kreskowiak, OriginalGriff, Pete O'Hanlon My assignment is already finish now. Thank you so much. Image ouput https://drive.google.com/file/d/1P4hCoqVaQc_rdEIPf1nGtv3AwzmMqWw-/view?usp=sharing
N 2 May 2024 by Coding Notes
In Part 4, we added basic support for the shopping cart, and now we'll enhance and refine that functionality.
N 1 May 2024 by Pete O'Hanlon
You already asked a variation of this question here[^] and, as you have more context there, you should continue there. As I explained in my reply to you there, you need to use the index of the row and the index of the cell that you want to change...
N 1 May 2024 by OriginalGriff
OK, first off your image link gives "Access denied" so we can't gain any information from that and we have no idea what "logical error" you might be talking about: we have no access to your code when running with your data, no way to look at your...
N 1 May 2024 by OriginalGriff
Read the error message, it's very clear: JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifying a DeserializeRootElementName. Your JSON data contains two...
N 1 May 2024 by Member 7513082
I am trying to convert json string to xml in c# and parse the data from acctNo and availBal node in the same. But i am getting exception JSON root object has multiple properties. The root object must have a single property in order to create...
N 1 May 2024 by ras bry
I'm tired to fix my logical error in my datagridview, can someone please help me. Here my code. while (dr.Read()) { int id = dr.GetInt32(0); DateTime startBook = dr.GetDateTime(2); ...
N 1 May 2024 by Pete O'Hanlon
Your problem is on this line:dataGridView1(startBook_C, id - 1).Style.BackColor = Color.Blue As you can see, this looks like a method call. Are you trying to do something like this?dataGridView1.Rows[startBook_C].Cells[id-1].Style.BackColor =...
N 1 May 2024 by ras bry
Attention to all, I need your help I'm using c#. The error message said, the datagridview1 cannot be used like a method. Please help me to fix this issue. here's my code. private void ShowSchedule()//show color { string...
N 30 Apr 2024 by OriginalGriff
This isn't a question that makes any real sense as asked: the DataSet class isn't one that you would normally write any source code in - it's a class that is provided by .NET to interface between a data source and the DataTable object it returns....
U 30 Apr 2024 by Aggeliki Asimakopoulou
I have added a DataSet in my C# solution and I added a table adapter from a query and I don't know at all what kind of source code could be written inside a DataSet class and how could it be used. Does it playes a key role for creating crystal...
N 30 Apr 2024 by PauliKK
You might need to adjust the application manifest or compatibility settings in Visual Studio. This includes checking if your app is requiring specific Windows capabilities or if there are manifest declarations that differ in environments that...
N 30 Apr 2024 by glennPattonWork3
Hi All, I have written an 'app' in C# Visual Studio 2022. My dev machine is a Win 11, Version 23H2 Build 22631.3447 I am trying to run on a Win 11, 23H2 OS Build 22631.3447 machine. running the same version of .NET the executable will run on my...
U 29 Apr 2024 by pdoxtader
Just judging from what you've provided, it looks like you're doing all the work on the UI thread, and you're queuing up items via a timer. I suspect that one job isn't completing before another is started (how fast is your timer set to fire?). So...
U 27 Apr 2024 by Graeme_Grant
I asked Google C# capture mouse[^] and found this: Capture or Detect mouse click on or outside Windows Form using C#.NET[^] UPDATE Let us change the Google Search: c# movemouse[^] - there are 126,000+ results. The first result has a couple of...
U 26 Apr 2024 by G Schulz
I have an HookMouseCallback(int nCode, IntPtr wParam, IntPtr lParam) How do I use these out params in UINT SendInput( [in] UINT cInputs, [in] LPINPUT pInputs, [in] int cbSize ); I am also planning on doing this for keystrokes,...
U 26 Apr 2024 by Richard MacCutchan
It is the view that gets sorted not the source table. So you need to capture the DataView object and display the row from there. See DataView.Sort Property (System.Data) | Microsoft Learn[^] for an example.
N 26 Apr 2024 by Andre Oosthuizen
You are accessing the row at index 4, which is the 5th row in the DataTable which is why you get the vale of '150. Datatable indexes start from 0 - Dim size1 As String = table.Rows(3).Item("Size") If you want to sort the DataTable by the...
U 26 Apr 2024 by Member 10974007
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim table As DataTable = New DataTable("Players") ' Add 2 columns. table.Columns.Add(New DataColumn("Size",...
N 25 Apr 2024 by Pete O'Hanlon
This is too close to providing code that aids in writing key logging software. Over the years, we have had many requests to provide code to people that can be used maliciously. Now, you might have benign intentions, and if it were just you and me...
U 25 Apr 2024 by G Schulz
I am trying to make a simple macro thing, I want it to record messages such as the mouse inputs, but also things like page select. I plan on saving these into a list or array, and then just looping over them and sending to the computer. I am...
N 25 Apr 2024 by Pete O'Hanlon
There are two parts to this problem if you are keeping it simple, and assuming that your datagrid is entirely viewable in one screen. The first thing you need to consider is how to draw a selection rectangle. There's an article here[^] that...
N 25 Apr 2024 by Member 16239100
I want the datagrid rows to be selected using a selection rectangle like we do in win File explorer Can anyone please tell me how to make this kind of behaviour in our own WPF app. Right now i am making a File explorer kind of behaviour using the...
U 24 Apr 2024 by Ignatius Baron Rio
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using System.Windows.Media.Imaging; namespace...
N 24 Apr 2024 by Nicolas DESCARTES
How to implement authentication in Blazor and ASP.NET Core ?
N 24 Apr 2024 by Graeme_Grant
I did a quick Google Search wpf datagrid multiselect dragging with scroll[^] and found this working solution: DataGrid auto scrolling when doing selection - solved[^]
N 24 Apr 2024 by Graeme_Grant
This is a common question so I did a quick Google Search that many solutions for your question: winform trasparent image overlay[^]. Pick one that best suits your needs.
N 24 Apr 2024 by Golden Basim
i want show an image that contains png logo, this image must be transparent as it over another control (Camera Control). What I have tried: I tried this solution but the issue that the Image (in Transparent control) appears in back of the...
N 24 Apr 2024 by GabrieleTronchin
Some years ago, I had to implement an OPC UA Client and server with .NET. Here are some steps from my journey that may help you: - Nuget packages available are not working as expected. Use the source code directly from GitHub. - The first test...
N 24 Apr 2024 by Jens Madsen, Højby
Fixed: To get a pointer to the first char (or whatever), use 'Marshal.UnsafeAddrOfPinnedArrayElement(Buff, 0)' I believe that using GCHandle to pin 'Buff' isn't needed on a local variable, but you'd better check it!;)
N 24 Apr 2024 by Member 16239100
I want a WPF datagrid which can select the rows same as we can do in Win explorer. For the i have implemented some code and need some help in that. Here the autoscroll for up direction is working fine but for downside autoscroll its not working....
N 24 Apr 2024 by honey the codewitch
How to validate fields for things like data entry applications.
N 24 Apr 2024 by Graeme_Grant
Maybe that is not the best way to do what you want. Have a look at the free options in this google search: winform free pdf viewer - Google Search[^]
N 24 Apr 2024 by Golden Basim
MySQL Database contains huge data (more than 5Gb) and more than 300,000 of records in some table. Some Queries require to handle some of fields value before showing it to the user like this query : var pQuery = DB2.sales_main ...
N 24 Apr 2024 by PKlaus17
I did a WinForm application to view PDF files. I use WebView2 of Microsoft and CoreWebView2.Navigate(pdfFile). The PDF - file ist displayed fine, but I have problems if the PDF file has several pages. It shows me the first page and I get...
N 24 Apr 2024 by M-Badger
Assuming that you wish to change which function is called for different joystick inputs based on a configuration file then you could use something like the code shown below. You might want to try a more elegant solution if there are a lot of...
N 23 Apr 2024 by sdecorme
HI, Actually I've made a winform application that read buttons and axis of my joystick. My goal is to have a config file to set input list with functions list. for example I'm using Sharpdx but I can change if needed Clear = buttons1 Left =...
N 23 Apr 2024 by Member 16250042
Not working about js. $(document.ready(function () { $(window).bind('beforeunload', function () { $.ajax({ url: "SignOut.aspx", }); }); }));
N 23 Apr 2024 by Member 14770314
This only addresses code behind code. There is no solution for event handler or command handler that lives in a databound ViewModel. No solution for that. It forces code behind and not View Model implementation, or at least a partial mvvm solution.
U 23 Apr 2024 by Yevgeniy Shunevych
An introduction to Atata C#/.NET web UI test automation full-featured framework based on Selenium WebDriver
N 23 Apr 2024 by M-Badger
I've not tested this but it would appear that the MS interop library version that you are using doesn't know how to convert images into MathML or LaTeX format. So either you need to convert them to MathML or LaTeX in the document before saving...
N 22 Apr 2024 by Member 7920931
Get element clicked in a canvas. myCanvas.MouseLeftButtonDown += OnMouseLeftButtonDown; private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var layer = (Canvas)sender; var element =...
N 22 Apr 2024 by Pete O'Hanlon
It's been a while since I've done this but I'm pretty sure you are going to have to do stream.Seek(0, SeekOrigin.Begin); once you instantiate it.
N 22 Apr 2024 by AAKASH R from Unknown
VLV paginated group search not working in server. What I have tried: I use C# directoryServices to fetch it. when I implemented it I found that it was working find in windows 2022 server and the same was not working in windows 2019 server. It...
N 22 Apr 2024 by OriginalGriff
There are a few problems here. With your existing code, you need to re-think it as the documentation[^] is very clear: Remarks: You must keep the stream open for the lifetime of the Image. Since your stream is created and no reference to it is...
U 22 Apr 2024 by Ravi Bhavnani
After you set the Label controls' text, call Application.DoEvents();.� There's no need to call .Refresh() on the Label controls. Warning: The Form's message pump will respond to all events when executing Application.DoEvents();, including...
U 22 Apr 2024 by sami alhassan
Dear Sirs I am self learning to C# I am doing a project for Assets management I create user control showing two images (QRCode with BarCode) all ok ad these 2 images saved to sql DB by byte.but when I want to display them in the usercontrol only...
N 22 Apr 2024 by Avinash Korat
Here below is my code in which i try to update label controller which is directly placed inside a Form. I want it to be update after every single second. For that i suspend and resume the layout. But still it isn't updating any data on the...
U 22 Apr 2024 by Conduct dotnet
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the...
20 Apr 2024 by honey the codewitch
Scraping the web is easy with Visual FA. Here's an example of how.
20 Apr 2024 by Graeme_Grant
So the issue is the uniqueness of the key. Using a dynamic object is the cause of your issue. Each object is unique. This is easy to demonstrate. Create two instances of a class with the same values, then do a comparison. You will find that they...
20 Apr 2024 by Golden Basim
I need to get the latest purchases cost for every group based on Item , supplier, unit. and synchronization it to another location .. item 1, pack, Jone, ... item 1, pack, Mich, ... item 1, pack, Yasser, ... item 2, pack, Jone, ... item 2,...
20 Apr 2024 by Graeme_Grant
Like desktop apps, you should use multiple techniques to capture and handle errors in your app. Blazor is no different. This page lists a number of strategies that you should be using: Handle errors in ASP.NET Core Blazor apps | Microsoft...
20 Apr 2024 by Prasad Sathe
Data not loading on page refresh in blazor webassembly standalone app What I have tried: I have created a sample web app in blazor as webassembly standalone app, then I simply published this web app in a local folder and hosted it in the iis as...
19 Apr 2024 by Gerardo Gamo
I know this is very OLD, but NOW myself Im struggling with helping a project that of course also is very old, but anyway, as they are using Web forms or ASPX, here is what I have for anyone having the same issue 1. when working with ASPx, I...
19 Apr 2024 by Member 14224038
Hello, what is the best way to get previous character in A-Z, i am having some APIs that return character say 'E' & am thinking to write a function that will return me 'D' ( previous charater) is there any direct function in c# that returns...
19 Apr 2024 by Pete O'Hanlon
To add to the answers given above. You should never limit your code to just consider the latin alphabet; there are so many cases where you need to consider international users. Fortunately, this is very simple to cater for. In the following...
18 Apr 2024 by Richard Deeming
Given a char, you can subtract 1 to get the previous code-point: char input = 'E'; char output = (char)(input - 1); // Contains 'D' You just need to decide what range of characters you want to support, and validate that the input is within...
18 Apr 2024 by OriginalGriff
Yes: subtraction ... using System; public class Program { public static void Main() { string str = "Hello World"; foreach (char c in str) { Console.Write((char)(c - 1)); } Console.WriteLine(); } }...
18 Apr 2024 by Test Mail May2023
using System.Text.RegularExpressions; public class RegexStringReplace { public static string? Replace(string input, string rxPtrn, string rxSubPtrn, string value) { // Create a Regex object with the given pattern Regex...
18 Apr 2024 by OriginalGriff
I'm not sure what you mean by "I have no idea how to implement this method." since you clear have implemented it and got exactly what I would expect from that when it runs. So I can only assume that the example you give isn't representative of...
18 Apr 2024 by dzadel
Hello everyone. Let's say I need a C# method with the following signature: static string? Replace(string input, string rxPtrn, string rxSubPtrn, string value); The method replaces, for each input string that matches a regular expression pattern...
17 Apr 2024 by Zijian
Reusable codes for JWT security in business applications
16 Apr 2024 by Mishael Ogo
A look at a simple SQL builder for Dapper
15 Apr 2024 by OriginalGriff
To add to what Dave has said, the session is a Server side construct, not Client - so it's expiration is unrelated to user input unless that input directly causes the Client browser to send (or request) information from the server. Just moving...
15 Apr 2024 by Jo_vb.net
A workaround (not a solution) for improving two of the remaining issues: For private void SelectItemsInRectangle(Rect selectionRect, DataGrid dataGrid, object sender, MouseEventArgs e) you should use the version which was posted here as...
15 Apr 2024 by Dave Kreskowiak
Quote: i set the idle timeout for 2 minutes, ... then the session getting expired in 2 minutes It's doing exactly what you told it to do! You said expire the session in 2 minutes, so the session is expiring in 2 minutes. What did you think was...
15 Apr 2024 by sysproteam123@gmail.com
Hi, I am working on .Net Core 6(MVC) web application, i set the idle timeout for 2 minutes, when i am moving from one page to another page then the session is working correctly, but when i am staying on any particular page and i am moving the...