Click here to Skip to main content
15,881,882 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
Reusable codes for JWT security in business applications
by Mishael Ogo
A look at a simple SQL builder for Dapper
by honey the codewitch
Implementing a simple JSON parser with Visual FA
by Akram El Assas
Functional Programming in C# through Algebra, Numbers, Euclidean Plane and Fractals

All Articles

Sort by Updated

C# 

U 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...
U 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...
N 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...
N 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...
U 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(); } }...
U 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...
N 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...
N 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...
N 18 Apr 2024 by Member 16246257
I want to have a copy of on premise oracle database tables saved in parquet files. There are many different tables and owners in this database, so I decided to use DataTable to make this process as simple as possible. I am using ChoParquetWriter...
U 17 Apr 2024 by Zijian
Reusable codes for JWT security in business applications
U 16 Apr 2024 by Mishael Ogo
A look at a simple SQL builder for Dapper
N 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...
U 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...
U 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...
N 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...
N 15 Apr 2024 by Andre Oosthuizen
As Richard mentioned above, you have no code showing how you are going to loop through the mail items. You also need the 'Outlook.Items' and 'Outlook.MailItem' objetcs for it to work properly. Normally I will not show pointers with as little...
U 15 Apr 2024 by Member 15418280
I want to read email from outlook in excel macro i want to add some filter for fetching email like subject from date etc. What I have tried: I tried condition but not working below is the code. Public Sub CheckEmail_BlueRecruit() '...
N 15 Apr 2024 by Graeme_Grant
If you are using data binding, like in this article here: Data binding a ListView[^], then the ListView control becomes a view of the data, not the data container itself. Then you only need to show the properties as columns, as required. This...
U 15 Apr 2024 by Ismael_1999
I need to create a list view with 3 columns, but I need also 2 more columns with related data that should not be viewed. Is there a way to do this? Thank you. I use Microsoft Visual Studio 2022 and this application is in Windows Forms. What I...
N 14 Apr 2024 by Pete O'Hanlon
As an alternative to Ravi's answer, there is a quick and dirty "hack" that you can use, assuming you are using Windows Forms here. When you add an item into a listview, you are adding an instance of a ListViewItem. This class has a Tag property...
N 14 Apr 2024 by honey the codewitch
Implementing a simple JSON parser with Visual FA
N 14 Apr 2024 by M Imran Ansari
In addition to Solution-1, it's advisable to explore further on your own. It's likely that the `lastUpdate` column might contain some null values, triggering exceptions during calculations. You can also try to modify query handle this scenario by...
N 14 Apr 2024 by Ravi Bhavnani
There's no standard way to do this in Windows Forms. The alternative I use is to manage a ListView's configuration in another object and initialize and populate the ListView appropriately.� See this screenshot as an example:...
U 13 Apr 2024 by Member 14224038
Hello, need help in adding objects in dictionary, so when there is new object i am adding key & object but struggling with object because i cant cast it or am doing something wrong ? & it already has the key am appending value to list on same...
U 13 Apr 2024 by SproketCoder
I've been attempting to retrieve a table from the SQL DB based on user inputs, but I'm encountering the following error: "Format of the string does not conform to specification starting at index 0". The query I'm using is "SELECT * FROM...
N 12 Apr 2024 by OriginalGriff
Your command string is wrong: SELECT * FROM @Tablename WHERE Created_On >= '@StartDate' AND Created_On
N 12 Apr 2024 by OriginalGriff
Without your data and some idea what the error message is (and the actual data that generates it) we can't help you - and you have to remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type...
U 12 Apr 2024 by Member 11400059
Hi I have lambda query for get all of my record change in more then 7 days ago. my query is: var result = db.adss.Include(i => i.AdsTpyeFK).Where(i => i.updateFlag == true && i.AdsTpyeFK.name == "gold" && (DateTime.Now - i.lastUpdate).TotalDays...
N 12 Apr 2024 by Richard Deeming
Further to Pete's excellent answer, you can use the TryGetValue method[^] to avoid the double key lookup of ContainsKey followed by the indexer: if (!uniqueComp.TryGetValue(cmp1[i].name, out List list)) { list = new List(); ...
N 12 Apr 2024 by Pete O'Hanlon
Your code should look something like this:if (!uniqueComp.ContainsKey(cmp1[i].name)) { uniqueComp.Add(cmp[i].name, new List()); } uniqueComp[cmp[i].name].Add(... whatever the value is ...); Basically, you are testing to see whether you...
U 11 Apr 2024 by Akram El Assas
Functional Programming in C# through Algebra, Numbers, Euclidean Plane and Fractals
N 11 Apr 2024 by Andre Oosthuizen
From what I could make out of your code is that your 'SelectItemsInRectangle' method is only considering the visible rows in your DataGrid at the time that you make the selection. When you scroll, new rows become visible, and your selection...
U 10 Apr 2024 by Jo_vb.net
I think you have to calculate the rectangle position every time when it should move. Perhaps it is simpler to delete the rectangle which is on wrong position and create a new one on calculated position if needed. ...
U 10 Apr 2024 by Member 16239100
I am attempting to replicate the selection behavior of Windows File Explorer within a WPF DataGrid. Specifically, I aim to implement a selection rectangle that mimics the functionality of File Explorer's selection mechanism. Currently, I have...
N 10 Apr 2024 by Graeme_Grant
Quote: When Manager clicks either of the link, it hits the endpoint and their response is Captured in Database. To prevent sharing, the only option is for the intended recipient to log back in, then you verify both the account used to sign in...
N 10 Apr 2024 by Pete O'Hanlon
I'm afraid you need to go back to whoever gave you the requirements and explain this is a monumentally bad idea, and also impossible to implement. If one manager forwards it to another, you can't prevent that, and you can't change the contents of...
U 10 Apr 2024 by Vaithilingam Alagappan
When User raise a request for Access. User's Manager needs to approve the request through email. The email will have Approve and Reject link as API endpoint URL. i.e., Approve - https://example.com/api/approve, Reject -...
N 9 Apr 2024 by Pete O'Hanlon
So, what is it that you want to display as an image? The thumbnail that you would see in Windows Explorer? A detailed, scrollable view of the PDF? I'm going to assume that you want the user to actually see the PDF itself here. If this is the...
N 9 Apr 2024 by PhamLong301
I'm new in C# and I have create a scanner application by C# winform. Now I'm having a problem that when i use treeview for a folder and click in item inside (all items inside are images and pdf file). All image file format display normal in...
N 9 Apr 2024 by Richard Deeming
Each iteration of your for (int iR = 0; iR
U 9 Apr 2024 by Aggeliki Asimakopoulou
I have created a back - end application in C# with embedded microsft sql server. I am pretty new to crystal reports and I had created one but in a wrong way and I am trying to correct it. I almost don't remember how I created and I feel bad for...
U 9 Apr 2024 by honey the codewitch
Generate a web browsable interface to your archived TV show content
N 9 Apr 2024 by Thomas Schröter
@George: sorry, but StringBuilder IS the PREFERRED way to create strings from data objects. String concatenation is bad due multiple allocating multiple objects in the heap and copying values around. StringBuilder pre allocates a buffer and...
N 9 Apr 2024 by Member 10371658
I am working with .net core MVC project, in which i set the idle timeout and session expired, it should redirect to the session timeout page, where i am showing message to user, your session is auto timeout, but it's redirecting to the...
U 9 Apr 2024 by nirmalamari
I entered the right password for the key. But still this issue. is .cert file different from .crt or .cet file
U 9 Apr 2024 by Dave Kreskowiak
You told the SELECT statement to return only the columns from the Invoices table with the "Invoices.*": SELECT Invoices.* FROM Invoices inner JOIN Customers ON Invoices.custID = Customers.custID where Invoices.custID ... By the way, NEVER use...
N 9 Apr 2024 by nirmalamari
I am exploring the option to use Okta SAML authentication. Since my evaluation period expired for Okta not able to ask in Okta site, so I thought codeproject forum experts might help. When we register a website in Okta, we get a 509 certificate...
N 8 Apr 2024 by OriginalGriff
That's some odd code - you only add the button Click event handler if the picture box is clicked: button.Controls.Add(table); panel1.Controls.Add(button); pictureBox.Click += (s, ev) => ...
N 8 Apr 2024 by Pete O'Hanlon
I'm confused as to what your problem actually is here. In this part, are you saying you are trying to use this code to hook up to the click event? my code for control button in line button.Click += new EventHandler(this.btn_Click); call button...
N 8 Apr 2024 by Graeme_Grant
Nostalgic trip... I used Google Search: windows ce 5.0 get list of screens - Google Search[^] and found this: GetSystemMetrics (Windows CE 5.0) | Microsoft Learn[^] Has this paramater: Quote: SM_CMONITORS Number of display monitors on the...
N 8 Apr 2024 by Graeme_Grant
Set a debug breakpoint on the line: button.Click += new EventHandler(this.btn_Click); and make sure that the line is being hit. If it is, the app will pause on that line.
N 8 Apr 2024 by Stylus STYLUS
Can't conect button click with buton control My code for button Button btn = (Button)sender; var itemAndPrice = btn.Text; int sno = dataGridView1.Rows.Count + 1; string nazivartikla =...
N 8 Apr 2024 by OriginalGriff
It's been a long time since I did anything with Win CE, but ... as far as I remember, you can't have multi screens at all - and that would explain why Screen.AllScreens doesn't exist. I suspect you are going to have to rethink your project to an...
N 8 Apr 2024 by Michi Elsno
I'm trying to develop a Windows CE application in C# in .NET CF2.0 and wanted to know how to get an array of screens. Normally this is done with Screen.AllScreens, but in CF2.0 that is not available. How could I translate Screen.AllScreens to get...
N 8 Apr 2024 by Rod Kemp
Sounds like you are running into a SPF,DKIM, DMARC authentication issue. SPF is a DNS record that tells the receiving email server if the sending server is a valid sender for the domain in the from field of the email. In your case you have the...
N 8 Apr 2024 by Aggeliki Asimakopoulou
SqlDataReader doesn't read all columns and their values in C#. My query in Sql Managemnt Studio works perfectly. Where am I wrong there? Any help will be much appreciated. Thank you so much in advanced. sql = "SELECT Invoices.* FROM Invoices...
U 8 Apr 2024 by Member 11290735
using System; using System.Collections.Generic; using System.Linq; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using...
N 8 Apr 2024 by Pete O'Hanlon
As you are having a problem with a hosting provider, the best thing for you to do is to get in touch with GoDaddy and talk to their support team. You can find their support here[^].
U 7 Apr 2024 by Pete O'Hanlon
If you want to see the value before it changed, use the INotifyPropertyChanging interface and raise the event before you assign the new value. Both of these events have a name property that tells you which property changed.public class...
N 7 Apr 2024 by Richard Deeming
The PropertyChangedEventArgs Class[^] does not provide any way to pass the previous and current values of the property. If you want to access those values in an event handler, then you would need to create your own event args class - for...
N 7 Apr 2024 by OriginalGriff
If you mean this code: public string Name { get { return name; } set { object before = Name; name = value; OnPropertyChanged("Name", before, Name); } } And that you...
N 7 Apr 2024 by George Swan
I would suggest that your Master class has an event handler that handles the Person class Name property changed event. Something along these lines. using System.ComponentModel; using System.Runtime.CompilerServices; public class Program { ...
N 7 Apr 2024 by Graeme_Grant
I popped your question into Google Search and found many solutions. Here is the first one returned: Redirect back to login page after session timeout ASP.NET 5 MVC 6[^]
U 7 Apr 2024 by Member 16238522
Complimenti! Articolo interessante! Ѕе cerchi un' idea sս dove andare in vacanza vai su seViaggi
N 7 Apr 2024 by AtaChris
public class Person : INotifyPropertyChanged { private string name; public event PropertyChangedEventHandler PropertyChanged; public string Name { get { return name; } set { object before =...
N 7 Apr 2024 by Member 10371658
I am working on .net core 6 MVC project, in which i want to logout the user automatically and redirect to login page, after session idle timeout. please see the below code i have written in program.cs file: builder.Services.AddSession(options...
U 6 Apr 2024 by Member 16235587
You can use cropperjs library. In that library there is method called "setCropBoxData(data)" you can set your co-ordinates and a cropper-box will be build on top of that co-ordinates. There are multiple options to change as your use case , I...
N 5 Apr 2024 by OriginalGriff
Go back to the manufacturers and ask for tech support - you would need the device available to you and running to stand any chance of working out what is wrong and we have neither any access to it nor any idea what it expects! It's possible the...
5 Apr 2024 by Vimalsoft(Pty) Ltd
Good Day All its been years since i posted something, am a bit stuck on Something. i bought a GPS device from china and was given a Protocol document and i have written a TCP listening and hosted it on the server. i can use TCP test tools...
5 Apr 2024 by charles henington
using static System.Char; public class Character { //building off of Accepted solution const string Vowels = "AEIOUaeiou"; //the field represented by the implicit operators protected char value; ...
4 Apr 2024 by Mohammed Faci
How to leverage ChatGPT to Build an Automation Framework using the Page Object Model
4 Apr 2024 by honey the codewitch
If you're putting together templates or other messes using JSON and C# this may be the ticket for you.
4 Apr 2024 by Member 1131834
Hi, I know this is old but maybe it will help someone. I used the following code and it worked as expected. internal class Program { static void Main(string[] args) { ProcessStartInfo start = new ProcessStartInfo(); ...
3 Apr 2024 by Srijita Bhattacharya
System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=SmartInvoice StackTrace: at SmartInvoice.Pages.Master.Pages_Master_Index1.d__9.MoveNext() in...
3 Apr 2024 by OriginalGriff
To add to what Graeme has said, 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...
3 Apr 2024 by Graeme_Grant
The answer is in the error message "Object reference not set to an instance of an object". Check the model on the server side in the controller by setting a breakpoint on the return statement. Then check the properties for a null value.
3 Apr 2024 by OriginalGriff
To add to what Pete has said, x86 projects build for a 32 bit OS, while AMD64 are built for a 64 bit environment - you can't combine the two in a single executable as the CPU can't be switched between them at run time. So if you want to use a 64...
3 Apr 2024 by Pete O'Hanlon
First thing - try to run the project using Any CPU. See if that fixes it for you. If it doesn't, you will need to create an AMD64 specific configuration. From the menu, select Build > Configuration Manager. Select the Active Solution Platform...
3 Apr 2024 by Member 16235801
I'm encountering the error ".dll targeting 'AMD64' is not compatible with the project's target platform 'x86'" while building my project in visual studio 2019. What I have tried: Switched project target platform to x64 (if applicable). Cleaned...
1 Apr 2024 by Mark Pelf
Overview of new changes to EF8 – support for Row SQL returning Non-entities.
31 Mar 2024 by Graeme_Grant
AlternationIndex and IsSelected are both properties of a ListViewItem, so a standard Style.Trigger will not work. You need to use a MultiTrigger Class (System.Windows) | Microsoft Learn[^]. Examples are provided with that link, however here is...
31 Mar 2024 by Mike Hankey
I have a ListView control and I'm trying to create a style to; color alternating rows, which works, color the rows when hovering and selecting. The hovering and selecting is the problem, the default behavior does not allow me to change the...
31 Mar 2024 by GabrieleTronchin
A simple implementation of MartenDB. MartenDB is a .NET Transactional Document DB and Event Store on PostgreSQL. For more information about MartenDB
30 Mar 2024 by Pete O'Hanlon
If you want to annoy users, come up with a way to prevent them from being able to go back from your site. There is a way that you could, sort of, achieve this which is to open a new browser tab when you navigate into your site. Your users will...
30 Mar 2024 by Dave Kreskowiak
To directly answer the question of a "web app", no, you cannot touch the browser, or any objects in it, like navigation history, from your server-side code. Grant has given you the only options you have from non-privileged code, which does not...
30 Mar 2024 by GabrieleTronchin
In this project, I leverage MailKit to seamlessly manage email communication with a test MailService.
30 Mar 2024 by Graeme_Grant
I did a quick Google Search: js clear navigation history - Google Search[^] Found the following answer: Window: history property - Web APIs | MDN[^] Quote: For security reasons the History object doesn't allow the non-privileged code to access...
29 Mar 2024 by Perić Željko
Hello, When I right-click the navigate back arrow in my web browser, I can see a list of previous URLs. Is there a way to clear that history from code in a web app? All the best. What I have tried: Searched all over the Internet, and except...
29 Mar 2024 by GabrieleTronchin
ASP.NET API with a Custom SQL Configuration Provider
29 Mar 2024 by Andre Oosthuizen
To add to what Pete has stated above, you can loop through each URL and create an 'ImportUrlCreateRequest' task for each one, see CloudConvert API[^] With the below code I am using a list called 'importTasks' to store all the...
29 Mar 2024 by swapnilbhosale
var job = await _cloudConvert.CreateJobAsync(new JobCreateRequest { Tasks = new { import_first_file = new ImportUrlCreateRequest { Url =...
29 Mar 2024 by Andre Oosthuizen
You are correct in stating that you cannot directly inherit from value types like 'char' or 'int'. You can however create extension methods to add new functionality to these types by using a static class, for example, 'CharacterExtensions'....
29 Mar 2024 by Aggeliki Asimakopoulou
Hello I would like to create a class in C# with some functions extending char class. Example we have some methods like char.IsUpper char.IsLower and I need to create some additional methods and functions in order to be able to use it every time I...
29 Mar 2024 by Andre Oosthuizen
Not my field of expertise at all but I found the following which might point you in the right direction - System.Drawing.Image to SkiaSharp[^] MS Learn | System.Drawing.Common only supported on Windows[^] Convert System.Drawing.Icon to...
28 Mar 2024 by Pete O'Hanlon
The easiest way for you to add an unknown number of pdf files would be to use an array or list. Inside iterate over the collection to create the value and assign them to Tasks. It doesn't have to be any more complicated than that.