Click here to Skip to main content
15,884,473 members
Everything / Programming Languages / C# 3.5

C# 3.5

C#3.5

Great Reads

by Nithyaduruvan, Sathishkumar_P
This article describes about the export functionality of Excel sheet from WPF datagrid.
by FatCatProgrammer
StarReport: WPF-less GDI+.NET report component.
by Member 7874525
This how you can monitor your database changes
by SREENATH GANGA
Auto updating the exe if the latest exe is available in the network share

Latest Articles

by NikStar
Using OutgoingMessageProperties and OperationContextScope to implement authorization by http header for WCF client that communicates with non WCF-based web services.
by gggustafson
This article is a significant revision to the earlier version and introduces a new version of ViewFile.
by Ashwin. Shetty
.NET Delegates & its 5 different features (Func, Action, Predicate, Converter, Comparison)
by Mansur Kurtov
This article shows how to use reflections in C#.

All Articles

Sort by Score

C# 3.5 

24 Oct 2010 by Nithyaduruvan, Sathishkumar_P
This article describes about the export functionality of Excel sheet from WPF datagrid.
25 Jan 2013 by FatCatProgrammer
StarReport: WPF-less GDI+.NET report component.
21 Oct 2013 by Member 7874525
This how you can monitor your database changes
27 Jan 2015 by SREENATH GANGA
Auto updating the exe if the latest exe is available in the network share
11 Jan 2016 by Den367
Using System.Windows.Media library to create embroidery design of a glyph from true type font file
20 Jun 2015 by vaid_sumit
Achieving Low Coupling & High Cohesion by applying SOLID principles
20 Dec 2015 by Nick Polyak
continues explanation of basic WPF concepts - multibinding, control templates and styles
19 Feb 2016 by Wonde Tadesse
This is another solution in addition to Solution 1.User ThreadPool as shown below.ThreadPool.QueueUserWorkItem(o => plugin.PluginSendClass.SendMessage(e));
3 Feb 2017 by tranthanhtu.vn
In "REST - Overview" article, I were introduced the basic rules in RESTful, Can you show me how to implement in WebApi?Ok, in this article, we will learn how to implement those rules in WebApi using C#.Where could I get sourcode was used in this article?Please checkout the code at https://github.com
4 Feb 2011 by David Melcher
this.WindowSta...
2 Apr 2015 by Dr Gadgit
Written in C# and VS2010 as a class libary to be used in your own project.
16 Nov 2010 by jim lahey
XmlNodeList to List without using a loop:var doc = new XmlDocument();doc.LoadXml("");var xmlNodeList = doc.ChildNodes;var nodees = new List(xmlNodeList.Cast());hope it helps
30 Sep 2013 by Md. Rashim Uddin
How to download different types of files in asp.net
14 Nov 2013 by shijo joseph
An extension methods library which could do the equality comparison operations easily
3 Sep 2014 by debashishPaul
How to convert LINQ query to DataTable
21 Sep 2014 by Arora Sumit
Routing in MVC
21 Aug 2016 by OriginalGriff
Because the width of a string is not the sum of the widths of all teh characters, except in non-proportional (or fixed width) fonts.In a fixed width font all characters are the same width, so the string is the width of a character times the number of characters:WIIIIILL12222234But in a...
25 Aug 2014 by Anoop Kr Sharma
In this Tip/Trick, I am going to show How to create Simple Paint Application in C#
15 Apr 2015 by Mario Z
Hi, well the easiest way that comes to my mind is to do it with a LINQ like this:int[] nonMatching = n.Except(m).Union(m.Except(n)).ToArray();In short the n.Except(m) returns n array's items that are not found in m array, m.Except(n) does the vice versa and the Union will combine those two...
14 Jun 2012 by Sergey Alexandrovich Kryukov
Please see my comment to the question. You need to specify your application type or UI library you want to use. If you don't have preference, you should tell us about it, as "what would you advise".Now, very clear tutorial is — on what topic? Don't expect and look for tutorials on...
19 Nov 2012 by TheQult
A simple Mailinator clone developed in five minutes with the NetFluid framework
5 May 2014 by Gerald Gomes
This article will make an attempt to describe a basic way to start implementing animation in WPF.
9 Nov 2014 by Richard Dunkley
Demonstrates how to use the Yocto Project to get a custom Linux operating system with Mono up and running on the Raspberry Pi development board.
28 Apr 2015 by Hassan Alrehamy
JSON Deserialization in depth concept and Dictionary mapping. Special Thanks to Dr. Coral Walker
25 May 2015 by Maciej Los
I'd suggest to start here:Creating Resource Files for Desktop Apps[^]Working with .resx Files Programmatically[^]
3 Sep 2015 by OriginalGriff
First of, never fetch DateTime.Now more than once: it leads to intermittent problem around midnight which can really mess you up. Fetch it once, and use it for all checks.Then try:DateTime now = DateTime.Now;var receiveDetails = objDB.GetAllReceivedDetails().Where(a =>...
4 Dec 2015 by Andy Lanng
well I would do it like this:string s = "racecar";bool b = s == s.Reverse().ToString();but as you said not to use reverse:string s = "racecar";for (int j = 0; j
19 Feb 2016 by Mehdi Gholam
Try using Task :...Task.Factory.StartNew( () => plugin.PluginSendClass.SendMessage(e) );...
8 Nov 2016 by Niemand25
A simple way to place any ObjectListView inside a ComboBox
17 Aug 2010 by CPallini
Uhm..., the 'Strip' ? :-D
14 Jan 2011 by Ashish Tyagi 40
I made a little changes in your code and its working fine MailMessage message = new MailMessage(); message.To.Add("ashish_tyagi_20@yahoo.co.in"); message.From = new MailAddress("username@gmail.com"); message.Subject = "New test mail"; ...
18 Feb 2011 by OriginalGriff
Set up a Timer in the form. Set it's interval to a shortish period: say thirty seconds.Set up a DateTime. Whenever there is "activity" (however you define that) reset the DateTime to DateTime.Now.AddMinutes(30).In the Timer Tick Event check the current time against the timeout...
8 Oct 2011 by OriginalGriff
Use a Regex:(?)[^\/// Regular expression built for C# on: Sun, Oct 9, 2011, 07:37:07 AM/// Using Expresso Version: 3.0.3634, http://www.ultrapico.com////// A description of the regular expression:////// ...
20 Nov 2011 by Bernhard Hiller
That's far too obscure.All you need to do is store a reference to the TabPage instance which was removed from the TabPages collection of the TabControl. You may use the form where the TabControl is placed for that purpose.You could also create your own TabControl which has an extra property...
1 Dec 2011 by Sergey Alexandrovich Kryukov
Yes, there is a better way: write new application from scratch, using just the ideas from old application. The more you try to "reuse" the UI code, the more time you will waste — this observation was done on several projects.Of course, if you managed to separate non-UI code from UI...
14 Jun 2012 by Espen Harlinn
Most likely you can use the Graph# library[^].Best regardsEspen Harlinn
14 Jun 2012 by VJ Reddy
Please see this CodeProject article Graphical BinaryTrees[^]In this article it is written that "This article is about binary trees. A Binary Tree contains unlimited number of nodes, the nodes can be removed, added, searched, etc. Here we will discuss on how to make a binary tree on c# code,...
24 Jun 2012 by Sergey Alexandrovich Kryukov
The solution is simple: stop abusing PictireBox. This simple control class which could help you in simplest cases, not helping you here, only creates unwanted intermediate layer to eat up extra resources and waste extra development time giving nothing in return, compared to using a custom...
22 Apr 2014 by Sergey Alexandrovich Kryukov
The question is not silly at all; it is pretty deep and not trivial.Very basically: the ability to It does know that because an executable image in the .NET assembly carries...
29 May 2014 by Randy Kroeger
Created a POC that dynamically builds a predicate using Expression and Reflection.
17 Jun 2014 by gggustafson
This article presents a tool named SiteMapper that creates a Google site map and a user traversable tree
23 Jul 2014 by Saad_Mahmood
Expression Blend - Playing with Sample Data (WPF , Windows Phone)
19 May 2015 by Kornfeld Eliyahu Peter
RTFM...MSDN[^]:It is possible to use more than one specific catch clause in the same try-catch statement.
15 Jul 2015 by Bryan Tubbs
This article will show how to create and/or a list of a particular class type from a SqlDataReader object by dynamically creating a lambda expression to carry out the process of populating the list.
15 Jan 2016 by Dave Kreskowiak
OK, first and foremost, Microsoft does not support and actively discourages using Office Interop in non-user applications, i.e.: Services and web applications.Office was not written to support a non-interactive environment. You can have problems using Office Interop in your...
27 May 2014 by OriginalGriff
This is really easy - but it's hard to work out for the first time. For example, get a list of files, and group them by the date which is in the 2nd to 10th characters of the name, ignoring extensions. Easy!
12 Feb 2010 by Ilya Builuk
You can create Excel file dynamically from GridView and save it on the hard disk. Perhaps your clients have enough GridView's functionality? This is not quite accurate solution to your problem, but may also help to solve it:using System;using System.Data;using...
13 Jun 2010 by Kristian Sixhøj
// Get all drives on system and loop through themSystem.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();foreach (System.IO.DriveInfo drive in drives){ // Is this a CD drive? if (drive.DriveType == System.IO.DriveType.CDRom) Console.WriteLine(drive.Name);}
11 Nov 2010 by Abdul Quader Mamun
Form1 form1= new Form1();form1.Close();Form1 is the form class which you want to close if you want to close another form from current form. this.Close();If you want to close current form.Application.Exit();To close application.
22 Nov 2010 by Nuri Ismail
Please, forget about your 64 (OMG!) pictureboxes and draw the board yourself. Check out this[^] excellent CodeProject article for details on drawing the board and for the chess game implementation at all! [UPDATE - After the comment from OP]Well, it didn't changed anything for me....
24 Jan 2011 by Henry Minute
Your problem is probably because you are using the Image.FromFile() method. There is a known problem with this method, in that it locks the file.Use the Image.FromStream()[^] method instead and all should be well.
2 Feb 2011 by Sergey Alexandrovich Kryukov
First of all, I don't think System.Random gives predictable results. If you say so, would you please demonstrate your prediction? However, I'm not sure if the result of random generation is not correlated and obey required distribution. Even if it not perfect, it does not mean...
17 Feb 2011 by Sandeep Mewara
I am not sure whats the issue in implementation. Keep a timer control on the form and configure it for a given period. If user is not interacting for that given period then close the form/application.If you want to open a screensaver or a new form, based on the time lapsed in the timer, you...
7 Apr 2011 by OriginalGriff
SHA will not "encrypt/decrypt a file".It is not an encryption algorithm.It is a Hashing algorithm.If you generate a SHA from a file, you cannot get the file back from the SHA value. At all. Ever. Period.Did you really think that a 5Mb file could be "encrypted" into 128 bits, and...
5 Oct 2011 by Espen Harlinn
I guess you'll need to set up a Windows CE development environment as you describe - It's likely that the device supports the OPOS (COM base) /NPOS (.Net based) APIs.I suggest you head over to the Symbol Site[^], they usually provide the required info, but you have to dig around a bit...
5 Oct 2011 by Mehdi Gholam
Having worked with Symbol devices the packaging comes as a shock the first time, as you only get the device.You have two options for these devices programming wise :1) Visual C++ 2) .net Compact FrameworkI would recommend .net programming as it is much easier. Symbol has very good...
5 Oct 2011 by Richard MacCutchan
I find it difficult to believe that two people can write exactly the same question[^]!
5 Oct 2011 by André Kraak
You will probably want to respond the to the DataGridView.SelectionChanged Event[^].In its handler check if a single row has been selected then get the values from that row and place them in the text boxes.private void DataGridView1_SelectionChanged(object sender, EventArgs e){ if(...
10 Oct 2011 by Mehdi Gholam
Your best option is to create a third class as a helper and have Class1 and Class2 use the Helper.
12 Oct 2011 by OriginalGriff
"dose it mean that the file became an encrypted file?"No. It means it becomes a corrupted file.Encryption is a name for a specific process: transforming information so that it cannot be understood without reversing the process using the key value that was used to transform it. Just messing...
15 Oct 2011 by Sergey Alexandrovich Kryukov
You certainly can store the code in database, but running it will be way more difficult. To run code dynamically, you need to compile it, which is quite possible through CodeDOM. It actually works through regular C# compiler, and this compiler is always bundled with all versions of .NET and run...
15 Oct 2011 by Abhinav S
Using the @@identity column will help you out.Tryhttp://msdn.microsoft.com/en-us/library/aa933196%28v=sql.80%29.aspx[^]http://msdn.microsoft.com/en-us/library/ms187342.aspx[^]
15 Oct 2011 by Espen Harlinn
Use the OUTPUT Clause[^] - you'll find examples on how to use this at the bottom of the page.Input and Output Parameters, and Return Values[^] shows you how to access the output from .Net[Update]If you follow this approach you don not need to implement stored procedures to get the job...
30 Oct 2011 by Mike Marynowski
You are almost there.The problem is that everytime the timer ticks you update the slider value, which causes your slider value changed handler to fire, which sets the position on the video, causing it to skip.Use a variable to suppress the code in the slider value changed handler before...
21 Dec 2011 by thatraja
Check this article. Now you need to customize the things. JumpyForum: Inspired by Code Project Forum / Discussion / Message board[^]
7 Mar 2012 by Sunil_Sebastian
Duplicate Notifier for a List using ObservableCollection.
7 Jun 2012 by Matt T Heffron
This is an alternative for "Word wrap without cutting words"
2 Sep 2012 by Prasad_Kulkarni
Try this:This is how you can get datasource:
6 May 2014 by Sergey Alexandrovich Kryukov
Long running tasks are done using threads, not timers. The only one little problem with having some extra thread performing such a long running task under the UI is that you cannot directly operate UI from that thread. This problem is solved using UI thread invocation mechanism.You cannot...
14 May 2014 by CPallini
new breaks polymorphism. See, for instance, Polymorphism (C# Programming Guide)[^].
21 May 2014 by Maciej Los
Please, read all comments to your question. As i mentioned: 'if it works for you, then do nothing', but... Sergey Alexandrovich Kryukov is right: it depends on many factors...I'd suggest to read this: LINQ to SQL vs Entity framework [ Which one is better with .net 4.0][^] to find out major...
22 May 2014 by DamithSL
you can do it with Linq GridView1.DataSource = dtExcelRecords.AsEnumerable().Skip(6).CopyToDataTable();Ref:http://msdn.microsoft.com/en-us/library/bb396189(v=vs.90).aspx[^]
17 Jun 2014 by cjb110
A String To Brush Converter for WPF/Silverlight
20 Jun 2014 by SREENATH GANGA
Making a TextBox accept Regional Language Input (Malayalam)
4 Jul 2014 by Sergey Alexandrovich Kryukov
You did not add this button to anything in your UI. The missing piece is something likebtn.Parent = someParentControl; // such as Panel or Form// same as:sameParentControl.Controls.Add(btn);—SA
25 Jul 2014 by Kishor Deshpande
Methods which facilitate the conversion from string to value type
7 Oct 2014 by Maciej Los
You can't calculate strings. You need to convert it to numbers.Try Int32.TryParse[^] method.Example: String sNumber = "123,456,789"; int iDenominator = 12; NumberStyles numStyle = NumberStyles.AllowThousands ; CultureInfo culture = new...
9 Oct 2014 by VC.J
protected void Page_Load(object sender, EventArgs e) { Button testButton = new Button(); testButton.Text = "pleaseClick"; testButton.Click += new EventHandler(button_Click); form1.Controls.Add(testButton); ...
30 Nov 2014 by TheRealSteveJudge
Hi,let's have a look at an example Windows Forms application.Form1.csusing System;using System.Windows.Forms;namespace WindowsFormsApplication2{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } ...
19 Dec 2014 by Jameel VM
If you have any DateTime property in Movie class please initialize with current DateTime like below before save movieToCreate.DateProperty=DateTime.Now;_db.AddToMovies(movieToCreate);_db.SaveChanges();Hope this helps
3 May 2015 by VictorSotnikov
I have applied the "phrases similarity calculation" algorithm to a GUI form that displays what I call a "two-layer list"
23 Jan 2015 by Sergey Alexandrovich Kryukov
This is not an anonymous type; this is just a type obtained from type inference. Considervar stringBuilder = new System.Text.StringBuilder();string whatIsIt = stringBuilder.GetType().FullName;The last line will return "System.Text.StringBuilder", quite fully named :-); and the first line...
29 Jan 2015 by Zoltán Zörgő
Good one!You need to build dynamic expression. Something like this:var parameter = Expression.Parameter(typeof(user), "p");var property = Expression.Property(parameter, si);var check = Expression.Call(property, typeof(String).GetMethod("Contains"),...
9 Apr 2015 by Thomas Nielsen - getCore
That's not really a good idea.But essentially you can reuse your code behind in most parts and will have to rewrite the UI. If you seperated logics from presentation you should already have a business layer and the change is not that difficult.If you didn't and have a so-called fat...
12 May 2015 by Richard MacCutchan
No, the system belongs to the user, not the application. This is just the sort of question that spammers and hackers are always asking. And no one here is going to help you to become one of those annoying types.
19 May 2015 by Richard Deeming
This is due to operator precedence. Your code is equivalent to:if (("Call Time: " + searchResult[i].CreatedDate) != null){ sb.Append(Convert.ToDateTime(searchResult[i].CreatedDate).ToString("hh:mm tt"));}else{ sb.Append("" + "");}Since anything...
20 Jul 2015 by F-ES Sitecore
If the user spends 2 seconds per row it would take them 27 hours to look at your gridview. Returning that amount of data is a very bad idea for many, many reasons, some of which you are finding out now. Use paging or implement some sort of filtering\search. Why present data that is useless?
1 Sep 2015 by CHill60
As you are trying to start completely from scratch, probably the best way is to observe how the .NET Button class was written in the first place.The source code for that can be looked on the .NET Reference Source[^] site.Give it a go and if you hit problems come back with a specific question
27 Sep 2015 by Thomas Daniels
When you copy a file into another directory, you also have to specify a file name; right now you are copying to %AppData%\Master, but you have to copy to %AppData%\Master\FileNameHere.exe. Use this File.Copy call to copy the executable correctly:File.Copy(src, Path.Combine(dest,...
7 Oct 2015 by OriginalGriff
If your DELL PC doesn't have the required permissions, then the only way they are going to be able to view the files is get up, walk to the RACKSPACE PC and look at it's screen using it's keyboard and mouse...That's what permissions are there for: to prevent people who aren't authorised...
8 Oct 2015 by F-ES Sitecore
That code is exception handling, but pretty pointless handling. If all you are doing is re-throwing the exception then don't bother with the try\catch block. If you are going to rethrow then use just "throw" and not "throw ex" and you lose some exception context with you throw a new exception...
28 Oct 2015 by phil.o
A regular expression seems to be what you need here:using System.Text.RegularExpressions;Regex regex = new Regex(@"^(?[0-9]+)(?[^0-9]+)$", RegexOptions.Compiled | RegexOptions.CultureInvariant);string input = "12pcs";Match m = regex.Match(input);int quantity =...
14 Dec 2015 by Animesh Datta
Hello ,As per your requirement try this below codeDateTime date= DateTime.Now; string format = "ddMMyyyhhmmsstt"; Console.WriteLine(date.ToString(format)); and O/P will be15122015063146AM
23 Dec 2015 by CHill60
txtPrice.Text is a stringproduct.Price is an intSo yes, you have to convert the text to an integer before you assign it to the Price propertyI suggest using int.TryParse() to do the conversion - see How to: Convert a String to a Number (C# Programming Guide)[^]
3 Jan 2016 by JoaoSousa23
Using MVC, Entity Framework, ASP.NET5 Scaffolding, and Azure SQLServer you can create a web application that stores your information on an SQL Azure database. This demo shows you how to create a web application with MVC and Entity Framework 7, that communicate with a SQL Azure Database
15 Apr 2016 by Richard Deeming
The problem is that you are using string concatenation to build your queries. That leaves your code vulnerable to SQL Injection[^].You need to change your code to use parameterized queries instead. That means switching from the mysql_ methods to either MySQLi[^] or PDO[^].This SO...