Click here to Skip to main content
15,892,927 members
Everything / Programming Languages / C# 5.0

C# 5.0

C#5.0

Great Reads

by David Rogers Dev
Learn how to load related entities using the Entity Framework with simple examples
by Darko Jurić
SIR Particle Filter brief tutorial with samples in C#
by tetsushmz
This article explains how to dynamically create RDLC.
by Daniel Vaughan
Create best-in-breed cross-platform MVVM apps using Calcium for Xamarin.Forms.

Latest Articles

by Roman Kiss
Design and implementation of small tool, tester for exploring Azure IoT Hub with virtual MQTT device
by Ciumac Sergiu
Explains sound fingerprinting algorithm, with a practical example of detecting duplicate files on the user's local drive.
by Mansur Kurtov
This article shows how to use reflections in C#.
by Mahsa Hassankashi
This article enables you to generate table in any database such as Oracle, SQLServer, MySQL, SQLite, Sybase, etc. just by typing table name and its fields. Then you can use NHibernate facilities to make query for data layer.

All Articles

Sort by Updated

C# 5.0 

24 Feb 2024 by Member 12692000
Hi I'm trying to generate a pdf with some data (header, paragraph, table, footer etc.) using PDFSharp+Migradoc where the table data is taken from a WPF datagrid. But whenever there are many rows in the table the footer text is overlapping with...
6 Nov 2023 by Maciej Los
As far as i know there's no exact method to write mail message to *.pdf via PDFSharp library. But! there's a workaround... To able to achieve that you have to: - convert/save mail message as rtf (see: MailItem.SaveAs method (Outlook) | Microsoft...
25 Oct 2023 by Akshay malvankar
I have one url, for e.g., "https://www.[REDACTED].com/article/toDownload.pdf" After pasting url in browser, PDF gets downloaded. What I want is to download PDF and convert it into base64. Issue: But after converting the code into base64, it...
17 Oct 2023 by OriginalGriff
Start by checking what you actually download: what you will get from that likely to be an HTML page rather than a PDF file. To check, the simplest way is to download the data and save it to a PDF file locally then open it in a PDF viewer and...
4 Oct 2023 by snorkie
Consider changing the default value on the assessor. Then when its passed empty, you get the same result on the first set. class demo { public List NotifyEmail { get; set; } = new List(); public List NotifyPhone...
4 Oct 2023 by Akshay malvankar
// following is the class class demo { public List NotifyEmail { get; set; }; public List NotifyPhone { get; set; } public List Inspectors { get; set; } } I want to send the following data which means I...
4 Oct 2023 by Graeme_Grant
This solution should do what you want: How to default a null JSON property to an empty array during serialization with a List property in JSON.NET? [solution][^]
14 Sep 2023 by Gokulnath007
How to create a circular gauge in C# Winforms like the attached images? What I have tried: I tried with Default Gauges given in CodeProject. It is not customizable for my requirement. https://i.postimg.cc/0r5GRXkk/Arc-With-Color.png...
23 Aug 2023 by krishna kommaraju
C# console application how to save exception in txt file? I generated an error. It's not writing an error to text file. Is there any other way to do it? Currently, I created in text file in C:\ location in local. But in Test and prod server,...
19 Aug 2023 by itsathere
I am using ASP.NET Core 5 for API and it's working fine on the localhost but while deploying on a subdomain(GoDaddy shared server), it's not working and I am trying to find a solution for the same since last week. If anyone has an idea, please...
18 Aug 2023 by Member 16074055
This is several months late but might help someone in the future. From the two web.configs I notice you went from an InProcess to OutOfProcess hosting model. I did the same thing and got a very similar result. For me it threw the error waiting...
14 Aug 2023 by OriginalGriff
To add to what Graeme has said, you should never hard code a file path into your app - it requires you to change the app between development and release versions, which means what you release is untested. Use the Settings file instead - open the...
14 Aug 2023 by Graeme_Grant
Change this line: catch (IOException) to: catch (IOException ex) Now you can view the exception: catch (IOException ex) { Console.WriteLine(ex); } This should explain the issue that you are having. If still unsure, click on "Improve...
14 Aug 2023 by Dave Kreskowiak
How do you create the gauges? Well, you have the article that tells and shows you how. THAT'S HOW YOU MAKE THE GAUGES! We're not going to read it to you, do the work for you, nor can we understand it for you.
14 Aug 2023 by Graeme_Grant
Quote: I tried with Default Gauges given in Code Project. You have the source code, so you can modify it for your own needs. You just need to move the "green" from the inside to the outside. I would add a property to the control to select inside...
14 Aug 2023 by Richard MacCutchan
Plenty of examples to be found at circular gauge in C# - Google Search[^]
24 Jul 2023 by Amit Kumar
Hi, I have tried 5 times for submit my article it is not submitted. I am so tried and I have also post my issue after that I was not got any suggestion from your side. I was getting message that tag it and some others. What I have tried: Hi, I have tried 5 times for submit my article it...
13 Jul 2023 by Prasath Paramaraj
Already I am having a lot of data in Excel. I am trying to insert new data in that Excel, but it's not inserting. I am having 20 columns, but I am inserting a new row (few columns only contains data) in Excel. What I have tried: using...
13 Jul 2023 by Member 12702056
What is the difference between char zero and normal zero in c++? especially i mean in c++for example,char x=0;int x=0;and char x='0'or just like '0'what is the difference between all of them?what is the exact meaning of them?Please,help me :)What I have tried:I know that...
23 Jun 2023 by Pranav Shrivastava
i add products in listview, but i unable to print multiple rows data What I have tried: i use this code for print e.Graphics.DrawString(lvProductItems.Items[i].SubItems[0].Text + " " + lvProductItems.Items[i].SubItems[1].Text + " " +...
23 Jun 2023 by OriginalGriff
You are presumably running that code in a loop: if not then it';s not clear what i is doing. And if you run that code in a loop, you need to change the Point at which you print text to increment in the Y direction each time you go round. If you...
6 Jun 2023 by R S Gaur
basically i have an some coding knowledge in c# or c language but we have to no any idea how to start project and when we open new project how many pages auto created and what use of this page in current project What I have tried: i start new...
6 Jun 2023 by OriginalGriff
Microsoft provide instructions in a tutorial form starting here: Getting Started with ASP.NET MVC 5 | Microsoft Learn[^]
25 May 2023 by tbim
I am using C# in Visual Studio 2012 class library assembly, .Net Framework version 4.5.1. I am trying to decrypt a file encrypted using [^]GnuPG. Files are encrypted using a password and without using key files. If possible, I would prefer not to have to install GPG4Win or equivalent on the...
25 May 2023 by tbim
This has been working correctly for me for years. You have to have GPG installed, of course. Recommend placing in try/catch block with logging. Decrypt file: /// /// Decrypts the file using GnuPG, saves it to the file system and...
13 May 2023 by Member 12692000
Hi, I'm trying to convert a outlook message file i.e. .msg file to a .pdf file using PDFsharp library. Now, my goal is to make the pdf file looking identical to the msg file even if has tables, images or colored/formatted text. But my code is...
3 May 2023 by Graeme_Grant
You asked about IValueConverter... Here is how you would do it with a multi-purpose VisibilityConverter: public class VisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo...
3 May 2023 by Member 12692000
Hi, I'm trying to follow MVVM pattern and want to hide a certain grid in my WPF app where there are two conditions e.g. right now I've something like What I have tried: ...
3 May 2023 by Richard Deeming
For something this simple, you just need to add two triggers:
25 Apr 2023 by Ddev5a2
Solution send Calender Invite as an attachment(.ics file) to end user. Code Starts: static void Main(string[] args) { Console.WriteLine("Welcome"); var client = new SmtpClient("smtp.gmail.com", 587) { Credentials = new...
25 Apr 2023 by Ddev5a2
HI All,I am trying to send .ics file as an attachment to user by creating ics file and email from C# code it self.I am able to send ICS file saving in to a local drive and attaching to email.I would like to send ics file with out saving in to any drive.help me is there any way to...
25 Apr 2023 by Member 11633430
Instead of this line: msg.Attachments.Add(new Attachment(str.ToString(), contype));, which kept giving me an error, I wrote the contents of str to a file via... string strName = "Aname"; DateTime dt = DateTime.Now.AddHours(1); string strDate =...
4 Apr 2023 by sbsmanian
Hi,I am using visual studio 2012 and crystal report 13.5. I am using following coding for loading report to crystalreportviewer ReportDocument crystalReport = new ReportDocument();crystalReport.Load(Server.MapPath("Report_SalesOrder.rpt"));Report dsCustomers =...
3 Feb 2023 by Graeme_Grant
You need to use a CollectionViewSource[^] to filter your sub-collection. Microsoft have hte following example: How to: Filter Data in a View - WPF .NET Framework | Microsoft Learn[^] Here is a working example put together to demonstrate how to...
3 Feb 2023 by Member 12692000
I know there are quite a few posts on the internet regarding how to implement cascading combo box following mvvm in a WPF c# app but I still could not make it work in my case. Can anyone help me with this ? I have a model with some properties...
20 Jan 2023 by Member 12692000
I'm trying to add data to a table in a SQLite database by getting data from a excel file using the fastexcel library. But I cannot figure out how do I get values from specific cells/column of a row in a worksheet. Can anyone help me with this...
20 Jan 2023 by CHill60
From the examples they have given in that project, Read example 2 has this snippet var rows = worksheet.Rows.ToArray(); //Do something with rows Console.WriteLine(string.Format("Worksheet Rows:{0}", rows.Count())); It...
16 Jan 2023 by Member 12692000
When I perform edit on an existing record(SQLite database), just before saving the edit I want to store the previous values of all columns of the said database row using c# in my WPF window app and store it in a txt/log file. To do this I'm...
16 Jan 2023 by Richard Deeming
before.Except(after) will depend on the Bills class correctly implementing the IEquatable interface, or at the very least providing correct overloads of GetHashCode and Equals(object). before.Intersect(after, new BillsComparer()) will...
15 Jan 2023 by Dave Kreskowiak
There's various ways of doing this. Google for "sqlite database change history[^]" for techniques and discussions.
29 Dec 2022 by Graeme_Grant
To access properties via data binding that are not normally reachable, like the Columns.Count property of the DataGrid control, you can write a wrapper around the control and add a custom property. public class MyDataGrid : DataGrid, IDisposable...
29 Dec 2022 by Member 12692000
How can I dynamically get the column count of a WPF datagrid inside a viewmodel method following mvvm ? What I have tried: Essentially datagrid.columns.count to a int variable but using mvvm.
20 Nov 2022 by suneel kumar gupta
Modelpopup extender showing below script error Uncaught TypeError: Cannot read property '_events' of null at Sys.UI.DomEvent.addHandler (ScriptResource.axd?d=co5QUPy2Hub1TZ9kFn66FaXSuHubiNR6E4Wd-9hfFsA_PvE4i61VYpBo1xSbRUtPX7PuVHKiRDqCYe…:5) at...
20 Nov 2022 by Member 15838204
Delete the visible="false" property in panel
26 Oct 2022 by Ahmed Salah Oct2022
namespace program { class program { static void Main(string[] args) { int[] grade = new int[10]; int[] cre = new int[10]; string[] gpa = new string[10]; double[] gs = new...
26 Oct 2022 by George Swan
What I would suggest is to use generic lists rather than arrays as the list size is not a fixed value so you avoid the empty array cell value problem. Rather than have multiple if then else statements in your code you can calculate the results...
25 Oct 2022 by Graeme_Grant
You need to add a test statement in your second loop... for (int i = 0; i
15 Oct 2022 by Tamal Banerjee
I have a datagrid column which is bound to a string property called BDT What I have tried: Now, the actual data in...
15 Oct 2022 by Richard MacCutchan
You can use the SQLite Date And Time Functions[^] to convert the display.
14 Oct 2022 by OriginalGriff
Date based formatting only works on date based values: strings are not date based, and can contain anything. The problem is your database (or how you interpret data from your database) - you need to change it so that date based date is stored in...
2 Oct 2022 by Member 13548480
I have two database having identical schema and same table in both database. I want to iterate both database and want to compare each table in both database. My problem: How to iterate both database and where to put if condition to check whether it is same table from both database or not. What...
11 Aug 2022 by Member 12692000
I'm trying to make a simple WPF application where I can do CRUD operations on the selected row of a datagrid and all the related datagrid's and other controls view get updated instantly. In my app there are currently 2 tabitems, in the first...
6 Aug 2022 by Gerry Schmitz
The ObservableCollection (OC) is a "persistant" data collection that is bound to the "UI". Updates to the OC are reflected in the UI when items are added, removed, etc. In your case, you create a new OC every time it is accessed: public...
26 Jul 2022 by ahmed_sa
ProblemHow put image logo inside of generated bar code ?DetailsI make windows application to generate c# qr codeI success to do thatI work in visual studio 2015 windows form applicationsi using messagetoolkitqrcodeMy code generated qr code by c# as following...
26 Jul 2022 by Member 15674854
Creating a class: public class QRCodeEncoderDemo { public static System.Drawing.Bitmap CombinImage(System.Drawing.Bitmap bit,string destImg) { System.Drawing.Image img = System.Drawing.Image.FromFile(destImg); ...
25 Jul 2022 by ahmed_sa
I work on csharp I have two arrays of string A1 = [Watermelon, Apple, Mango, Guava, Banana] A2 = [Orange, Kiwi, Apple, Watermelon] i need to write code by csharp get difference between two arrays and display difference between two arrays but...
25 Jul 2022 by PIEBALDconsult
Dictionary Iterate the first list, adding strings with int 1. Iterate the second list, adding new strings with int 1, adding 2 to the ints of existing entries. Any item in the dictionary with int 3 is in both lists. But I'd use a HashSet.
25 Jul 2022 by OriginalGriff
Simplest solution (that works for large data samples, rather than just the tiny ones you have there) is easy: Sort the two arrays. Now each array is in order and a simple loop will enable you to see what is different. Think about it: A1) [W A M G...
19 Jul 2022 by n.deny
i want to read and write the data using FT232rl module in c#. i made a connection but didnot get access to read and write the data.please help!!!!!!!!!!! What I have tried: //for connection private void Button1_Click(object sender, EventArgs...
15 Jul 2022 by Govardhanudu Gajula
Hi friends, when i am trying to get the data from Gridview to excel data, when i am open the excel file, the file you are trying to open fileanme.xls is in a different format than specified by the file extension, when i click yes in that time only excel is open, but my client requirement is we ...
3 Jul 2022 by Member 12692000
I'm trying to show the column values of the selected row of a wpf datagrid to different textboxes without breaking the mvvm pattern. I'm relatively new to the mvvm. Here is my XAML:
6 Jun 2022 by Member 15663501
Because You are Refering Mutiple Table As reference.i has faced same issues.resolved,Mutiple TABLE REFERING
1 May 2022 by uttamkumbhar
I want catch the user perform or not on computer. What I have tried: I have tried windows service, but result failed.
1 May 2022 by Graeme_Grant
I did a quick Google Search[^] and I think that this is what you are looking for: windows - C# - Detect time of last user interaction with the OS - Stack Overflow[^]
15 Apr 2022 by Levente Tóth
So I've tried to write a code which tells my that i can built a line with dominoes using all of them. the output is good for some of the inputs but not all of them. Can someone take a look at it? For example my input: 2 1|6 6|3 Here i got good...
15 Apr 2022 by Patrice T
Quote: I can't find where is it going wrong Your code do not behave the way you expect, or you don't understand why ! There is an almost universal solution: Run your code on debugger step by step, inspect variables. The debugger is here to show...
15 Apr 2022 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email...
12 Apr 2022 by Member 11159188
Hi All, I am working mvc 5 .net core 3.1 web application, i have implemented Saml Azure AD authentication with web application authentication working as we expected but Claims cant able to save the in application after the successfully login . ...
12 Apr 2022 by Rajeev Jayaram
You might have not configured/implemented the authentication middleware properly. Have you included all code related to SAML authentication from GitHub - cmatskas/aspnetcoresaml[^] Check in your Configure Services, ".AddWsFederation" options...
6 Apr 2022 by ArdaKaya19
Nothing happens when I double click on the timer tool on the form What I have tried: Nothing appears on the lightning icon, only a tick.
6 Apr 2022 by OriginalGriff
Try to give better information in future, it makes it easier for us, and quicker for you to get an answer to your question. Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work...
6 Mar 2022 by Member 9129971
I have a c# webapi having angular web and android, ios apps.I am going to use simple token based authentication.Token is issued at login time and used for future requests.The problem is that how can i devalidate/logout a token of a specific for different devices like web(this also includes...
6 Mar 2022 by Abdo AJ
Hi There ! you already done the half of it you can Store data in JWT such as device unique identifier or any other data that helps you identify the user and get it at every request for the clint side there a payload section at jwt allow you to...
20 Feb 2022 by Roman Kiss
Design and implementation of small tool, tester for exploring Azure IoT Hub with virtual MQTT device
14 Feb 2022 by ravithejag
I am trying to connect to SVN via Visual Studio 2019 and the .NET 5 framework. My requirement is to get the list of repos under SVN. I am able to move the repo from one SVN repo to other, then upload the code to SVN. All the mentioned items have...
14 Feb 2022 by M Imran Ansari
Your SharpSvn dlls are not getting resolved properly. Check the dlls you are using and Target Framework. If you are targeting to x86, use the x86 dll, or if your target is x64 then use the x64 dll to resolve this issue. If you are getting this...
6 Feb 2022 by Abdul Khaliq 2022
string[] jpg = Directory.GetFiles(@"D:\Image", "*.jpg"); string[] png = Directory.GetFiles(@"D:\Image", "*.png"); int count = 1; string no = "No"; string name = "Name and location of file"; ...
6 Feb 2022 by Richard MacCutchan
string pathToFileToDelete = jpg[indextoremove]; You are using indextoremove as the index into the array of file names. But the value entered by the user is the file number, so it should be indextoremove - 1. But you also have the problem with...
6 Feb 2022 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email...
5 Feb 2022 by Abdul Khaliq 2022
static void ViewImageFolder() { string[] jpg = Directory.GetFiles(@"D:\Image", "*.jpg"); string[] png = Directory.GetFiles(@"D:\Image", "*.png"); int count = 1; string no = "No"; ...
5 Feb 2022 by OriginalGriff
Your jpg array contains full paths to files, so unless the indextoremove contains exactly the same string (which is unlikely given the variable name) this code isn't going to return anything useful: int numIndex = Array.IndexOf(jpg,...
21 Jan 2022 by Member 13489621
Hi, I am developing a multi-client/single-server project that communicates through sockets. Server Go: The main program listens to a new connection, when a client connects to the server it's handled by a goroutine. On the goroutine I have a...
21 Jan 2022 by Greg Utas
A serious server will be implemented with synchronous (blocking) sockets. Each socket has a thread that waits for stuff to arrive on its socket. All this thread does is put messages on a work queue that an application thread will service. The...
20 Jan 2022 by RickZeeland
You can find an example here: Asynchronous Client Socket Example - .NET Framework | Microsoft Docs[^] If you have a lot of traffic you also might consider queueing.
18 Jan 2022 by Georgiev Tihomir
Hello everyone, I write this code, but I cannot explain where is the Problem here, that output cases not match. Given a string, S, of length N that is indexed from 0 to N - 1, print its even-indexed and odd-indexed characters as 2...
18 Jan 2022 by Patrice T
Quote: Write a code in C# from the Task, but in output cases does not maches. You forgot to tell us the actual output. Tell what output is not, is no help to us, telling what output is, can help us to understand what is going on. Your code do...
17 Jan 2022 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email...
5 Jan 2022 by nguyenvanngon
Hello all. i have a tuple (exam tuple iTuple=new tuple("A",1)).I want to change value how iTuple.Item2=3. How change? Thanks all
5 Jan 2022 by Dennis McEnaney
Possibly a bit overkill for most situations, but you could consider wrapping the (tuple) items with a container type - the Tuple indirectly referencing each of the items (via the container type/instance), whereby you can change the container's...
1 Jan 2022 by Adam Flow
As stated in this wiki: Fluent NHibernate Any Quote: There are three things you need to provide to be able to map using an Any; a column that holds the type of the entitiy, at least one column holding the identifier value, and a type for the...
1 Jan 2022 by Member 9614352
I am new to Nhibernate and I don't know how to create a polymorphic relationship/mappings in my application. I have tried different solutions and tutorials but unfortunately I am still not been able to figure out how can I make this work. Following is my database structure in which...
29 Dec 2021 by boshra alawneh
USING C# PROGRAMMING LANGUAGE You are asked to write a code design, implement, present, and discuss a game called Fruit Collector (FC). FC is a game for kids that allows a player to collect fruits which appear randomly. Every time the player...
29 Dec 2021 by RickZeeland
Maybe these tutorials will get you started: How to make a platform game in windows form and c# in visual studio - YouTube[^] Create a matching game - Visual Studio (Windows) | Microsoft Docs[^]
29 Dec 2021 by CHill60
No, we will not do any of your homework for you. Nor is tutoring you appropriate in a Quick Answers forum. Please understand, if we were to do your homework for you it does not help you at all. You still won't understand the process and that...
17 Dec 2021 by ahmed_sa
I work on csharp i need to get value of period and Start date from variable productData so how to get data of start date and period from ProductData string variables using csharp string productData = Serial No :444909812 ItemType :Electricy User...
17 Dec 2021 by OriginalGriff
Try a Regular expression: (?:Start Date :)(?\d\d\d\d/\d+/\d+)(?:.+?End Date :)(?\d\d\d\d/\d+/\d+) Will split out the date info from your examples, and you can then use DateTime.TryParse to convert them to DateTime objects.
1 Nov 2021 by Twist Brave
//Programing in C language Use an array of size 10 to implement an odd number stack and an even number stack in the same array. The odd numbers will be inserted from the left side of the array and even numbers will be inserted from the right side...
1 Nov 2021 by Patrice T
Quote: Use an array of size 10 to implement an odd number stack and an even number stack in the same array. You are requested to implement 2 stacks in 1 array of 10. This means that your program must be able to store any mix of odd/even numbers...
1 Nov 2021 by OriginalGriff
You can't use copy and paste code from the internet for a stack and expect it to meet your assignment: you need to use an array in a different way. You need two indexes: top_left and top_right together with the functions your teacher describes: ...
1 Nov 2021 by CPallini
Well your code apparently does NOT fulfill the requirements. It is a staring point though. You have to duplicate some variables (e.g. top: you need something like top_even and top_odd) and function (for instance you do need two insert functions)....