Click here to Skip to main content
15,886,788 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 Score

C# 5.0 

24 Jul 2014 by David Rogers Dev
Learn how to load related entities using the Entity Framework with simple examples
27 Apr 2015 by Darko Jurić
SIR Particle Filter brief tutorial with samples in C#
2 Jan 2014 by tetsushmz
This article explains how to dynamically create RDLC.
15 Sep 2014 by Daniel Vaughan
Create best-in-breed cross-platform MVVM apps using Calcium for Xamarin.Forms.
5 Aug 2014 by Magyar András
How to create Office 2013 style splash screen for Windows Forms
4 Sep 2015 by Afzaal Ahmad Zeeshan
This post attempts to describe the general difference between overloading and overriding in Object-oriented programming languages.
31 Aug 2015 by markmnl
Overview of making fast-paced multiplayer networked games - the challenges and techniques to overcome them.
22 Mar 2017 by raddevus
Part 1: Master the ASP.NET MVC Project Template & Technologies (Razor, jQuery, JavaScript, Bootstrap, CSS). Part 2: Build an ASP.NET MVC app which runs in the browser but feels like using a desktop app.
1 Jun 2014 by S. M. Quamruzzaman Rahmani
ASP.NET team released Identity framework 2.0. The new release contain some new features like generic primary key. This article explain how to change primary key from string to integer & use it with MVC5.
20 Feb 2022 by Roman Kiss
Design and implementation of small tool, tester for exploring Azure IoT Hub with virtual MQTT device
21 Nov 2014 by CodeFate
Revision of the Global Mouse and Keyboard Library from Brian Geiman
31 Aug 2016 by Sheshnath Kumar
This article will find out a solution to serialize/deserialize object by reference at server and client, also will serialize/deserialize objects having circular references.
27 Jan 2015 by SREENATH GANGA
Auto updating the exe if the latest exe is available in the network share
4 Jan 2016 by tetsushmz
This article shows how user inputs can be validated dynamically with FluentValidation and INotifyDataErrorInfo in a WPF/MVVM application.
16 Nov 2014 by Sergey Alexandrovich Kryukov
It supports only so called "weak form of multiple inheritance": each interface or class can have any number of types in its inheritance least, but the first type listed should be a class, and all other types can only be interfaces. In other words, this is multiple inheritance for interfaces; and...
2 Apr 2015 by ChRi$m0rG@N
An article about an omni directional Arduino Yun robot, and an alternative .Net implementation of CmdMessenger
17 Sep 2014 by Daniel Vaughan
Create a Xamarin Forms tabbed page or carousel page by binding to a collection of ViewModels; extending beyond the current capabilities of Xamarin Forms.
20 Jun 2015 by vaid_sumit
Achieving Low Coupling & High Cohesion by applying SOLID principles
24 Nov 2014 by Christian Kleinheinz
Using the .NET OpenFileDialog and SaveFileDialog for an application in multithreaded apartment mode (MTA)
5 Sep 2015 by Maxim Kurayan
EF Dynamic Report is a small open source project which allows you to use Entity Framework mapping between types and tables as a dynamic report data source
3 Sep 2014 by debashishPaul
How to convert LINQ query to DataTable
30 Nov 2015 by Mohammad Dayyan, VahidJafari
A library for creating .Net Serializable Expressions to send via WCF services
21 Dec 2014 by arussell
How to use C# to create WPF 3D graphics.
31 Jan 2015 by Ryan Scott White
A quick C# reference for FileSystemRights enumeration in table format.
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...
20 Apr 2015 by Mario Z
Hi, try this:var application = new Application();var document = application.Documents.Open(FileName: @"C:\Sample In.docx");var tocRange = document.Range(0, 0);var toc = document.TablesOfContents.Add( Range: tocRange, UseHeadingStyles: true);toc.Update();var...
15 May 2015 by Thomas Daniels
A Tuple is immutable. So you have to create a new one if you want to change the value:Tuple iTuple = new Tuple("A", 1);iTuple = new Tuple(iTuple.Item1, 3);
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.
9 Jan 2015 by OriginalGriff
No.If you aren't sure if your app does what you want, run it! (Preferably in the debugger so you can watch what is happening.)The question asks you to read numbers from the user and print them out again, until he enters 42. Your code doesn't do that. And if you run it, you will see what...
19 Jan 2015 by defwebserver
You can implement SharePoint documents in your AngularJS applications much easier when you create your code in a Visual Studio LightSwitch Cloud Business app.
19 Mar 2015 by Hrvoje Batrnek
Easy and seamless caching implementation of any virtual method in any class
21 Mar 2015 by Amit Singh Baghel
A useful tip to export a Div to PDF (with Unicode support) with the help of NReco-PDF Generator for .NET (C#), JQuery and Handler in ASP.NET
26 Mar 2015 by Gaurav Aroraa
In this article, we will discuss basics of Azure API Management to manage our Web API.
21 Apr 2015 by Yaseer Mumtaz
This small tip will explain how you can check status of long running processes in ASP.NET MVC web application using SignalR by sending messages from server to client during execution.
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 =>...
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 Nov 2012 by Nayeem Mansoori
You need to set as startup project.Right click on your project and click set as startup project than will run your projecti hope this will help for you.bye..
29 May 2014 by Thang Believe
Deep dive into cookies generation to support Remember Me at login
23 Jul 2014 by Saad_Mahmood
Expression Blend - Playing with Sample Data (WPF , Windows Phone)
5 Oct 2014 by morzel
How to shoot paintball marker with relay, Arduino and .NET Winforms
15 Oct 2014 by Sergey Alexandrovich Kryukov
First of all, you can never have two primary keys: http://en.wikipedia.org/wiki/Unique_key[^].Don't confuse this statement with the situation when you can have a compound key, which can be uses as a primary key, but it still has to be unique:...
30 Oct 2014 by Mathew Burnett
A very simple program to kill all network interfaces if your VPN goes down.
22 Dec 2014 by Turay Melo
This is an alternative for "Creating an Outlook 2010 Add-In"
29 Jan 2015 by Richard Deeming
Your code is vulnerable to SQL Injection[^].NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.using (SqlConnection conn = new SqlConnection("Data Source=UNITECHSYSTEM\\SQLEXPRESS;Initial Catalog=Rajj1;Integrated Security=True"))using (SqlCommand cmd...
17 Feb 2015 by PFalkowski
The way of calculating amount of memory occupied by some object in C#.NET
5 Aug 2015 by Philippe Mori
When you write 1 / 3, it is an integer division and this the result is 0.0. To make floatting point division, at least one of the operand must be a floatting point.Also, you should not mix decimal and double without reason. Less conversion is better.
25 Aug 2015 by KarstenK
You can improve the quality a bit with interpolation. Like the Open Source VLC Player does. But normally you cant win much with it.The common way would be to apply some image effects like in the outstanding CXImage project for EVERY frame.All not very well, so the best way is to get high...
4 Jan 2016 by levelnis
How do you post to a Web API controller from an MVC controller?
24 Mar 2017 by raddevus
Building the ASP.NET MVC desktop UX (User Experience). See ContextMenu in action.
14 Feb 2014 by BenScharbach
How-To Convert a String Collection to a Multi-Enum item using TryParse
29 May 2014 by comiscience
Make changement of reporting easier. Unity help us
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
15 Jul 2014 by Maciej Los
It's impossible!Please, have a look at past discussion[^]
12 Sep 2014 by Sergey Alexandrovich Kryukov
Use one of the many languages and development systems targeting native Window (or some other) OS. Using CLR without .NET installed does not seem really realistic. Better yet, ignore the problem. Develop for .NET and relax. First, there are less and less systems without .NET out there; secondly,...
2 Oct 2014 by Peter Leow
Check these out:1. Useful Reference Books[^]2. A Gallery of Useful Programming Books[^]
4 Oct 2014 by CPallini
This way the class consumers can set the date only via the constructor. This is a legitimate design choice making every DateClass instance a de-facto const.[update]As Sergey correctly pointed out, I overlooked setters are never used in the class. That makes them useless and the class...
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); ...
5 Nov 2014 by PIEBALDconsult
A Scheduled Task should be enough, but you'll be irritating and possibly losing your customers.
7 Nov 2014 by Sinisa Hajnal
Or you could try this solution[^]Note that it isn't absolute protection, but definitely makes it harder to reverse engineer your code.If this helps please take time to accept the solution. Thank you.
21 Nov 2014 by Daniele Rota Nodari
VB.NET Chr(i) and C# (char)i are not equivalent.To obtain the same behavior, through VB.NET you have to call ChrW function instead of Chr function.The first one (ChrW) accepts UNICODE values (between -32768 and 65535), whereas the second (Chr) accepts ASCII values (between 0 and...
25 Nov 2014 by David Killian
A reflective approach to providing stored procedure based data access methods with a reuse pattern based on polymorphic Types as arguments in ObjectResult
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(); } ...
7 Mar 2015 by phil.o
The minimum you need to write it is a text editor; but a decent IDE is a more appropriate choice. The most obvious example would be Visual Studio, but you can also use Mono, or Eclipse if developing in java is not a concern.Otherwise, you develop it the same way as any other software:1)...
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...
10 Apr 2015 by Thomas Daniels
This might be the case (quote from MSDN):https://msdn.microsoft.com/en-us/library/system.io.file.move%28v=vs.110%29.aspx[^]If you try to move a file across disk volumes and that file is in use, the file is copied to the destination, but it is not deleted from the source.
11 Jun 2015 by OriginalGriff
You can't necessarily do that.An array of char[][] or Listis a jagged array - not all the elements in the collection are defined as being the same length.For example:char[][] arr = new char[][] {{'1','2'}, {'1', '2', '3'}, {'1', '2'}};You can't convert that to a char[,] array...
3 Aug 2015 by F-ES Sitecore
4 / 2 is 2 which is not 0 so your code is saying it is prime. Your code seems to be checking for odd\even rather than prime. There are mathematicians who have dedicated their lives to working out if numbers are prime, and (as for as I know) no solution has yet been...
19 Aug 2015 by Mario Z
Yes it is possible, you can find the method here[^].Also you can use the following VS extension to do this inside a VS as well:Ref12[^]
28 Aug 2015 by Sergey Alexandrovich Kryukov
Wrong question. First, video is not converted to audio (what it would even possibly mean?) It's just video files contain several streams, and some of them are video, and some are audio, and you can have some different kinds of streams (subtitles, for example). So, you can first extract some...
16 Sep 2015 by Sergey Alexandrovich Kryukov
One way to preserve some file from modifications or deletion, regardless of privileges, is to keep it permanently open in some process, for non-shared access (which is the default). To keep this state permanent, the code should also be executed permanently, which is possible if this process is...
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,...
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 Feb 2016 by adityasahver
In this article, we will learn how to create an Tile/Page in the MS Band and trigger the details on the associated device
2 Mar 2016 by Dave Kreskowiak
Next time, just put the code in the post, not in an image.No, you're wrong about the "8 bytes".The top code snippet in the image is just a shortcut, an "auto-implemented" property. Behind the scenes it's doing exactly the same thing as the second code snippet in the image.In both...
8 Mar 2016 by Mohammad_Imran
In your code "this" is used overload the constructor.The this() syntax instructs the compiler to insert the specified constructor that matches the parameter list specified.eg: public class User{ string firstName,lastName; int Age; public User(string...
16 Mar 2016 by F-ES Sitecore
double is an approximation of the number, the maths is quick but not guaranteed to be 100% accurate. If you need accuracy use decimaldecimal dr = 495494.3948402M + 3740.9729811M;
16 Mar 2016 by Jochen Arndt
Most floating point numbers can not be represented exactly on computer systems and performing operations usually leads to additional errors. See Round-off error - Wikipedia, the free encyclopedia[^] and The Floating-Point Guide - What Every Programmer Should Know About Floating-Point Arithmetic[^].
24 May 2016 by Karthik_Mahalingam
try thisDont create the instance of the list inside the loop. List> kvpList = new List>(); foreach (XmlNode xn in xmlLabelList) { string propert = xn["name"].InnerText; string label =...
1 Jun 2016 by Matt T Heffron
If you must modify an array in place then when you delete an element, you need to copy all of the following elements down one position, and put the zero at the end position:int [] marks = new int[5] { 1, 2, 3, 4, 5};int deleteAtIndex = 1;for (int i = deleteAtIndex; i
15 Jun 2016 by Allen C. Copeland Jr
Grokking the CLI - Part 1: Meta Mayhem
2 Oct 2016 by dileep
This post explains how to implement CRUD Operations in the MongoDB by using C#.
13 Jun 2011 by Sergey Alexandrovich Kryukov
A global hook only helps if you need to consume all available event. You can do it using P/Invoke and Windows Hooks. See http://msdn.microsoft.com/en-us/library/ms632589(v=vs.85).aspx[^].If you want to write a system-global hook, you need to write a native DLL which installs the hook. I...
5 Apr 2014 by Pragmateek
Synchronization, Memory Visibility and Leaky Abstractions
16 Apr 2014 by Matthew Dennis
public List names = new List();while(reader.Read()){ string name = reader["FirstName"].ToString().ToUpper()); if (!names.Contains(name)) names.Add(names); else { // handle reporting the duplicate here }}If the list is...
25 Mar 2018 by Matej Pavlů
Creating a replacement for missing TileBrush known from WPF.
22 Jun 2014 by CHill60
Instead of the lineusing System.WinForms;which produces the error Quote:The type or namespace name 'WinForms' does not exist in the namespace 'System' (are you missing an assembly reference?)Use the correct version using System.Windows.Forms;That will get you down to only 4 compile...
2 Jul 2014 by OriginalGriff
If you mean intermittent errors: ones that happen occasionally, but are difficult (or impossible) to reproduce, then there is no one way to find them. They are the hardest problems, and the biggest tests of developers everywhere.But there are things you can do: look at the error, and try to...
19 Aug 2014 by Alberto Nuti
How to serialize an object without having to manually instruct the DataContractSerializer class.
4 Sep 2014 by Gihan Liyanage
DateTime today = DateTime.Today;DateTime endOfMonth = new DateTime(today.Year, today.Month, DateTime.DaysInMonth(today.Year, today.Month));
8 Sep 2014 by Sergey Alexandrovich Kryukov
As to the process starting and termination events, please see this CodeProject article: Hooking the native API and controlling process creation on a system-wide basis[^].As to activation and deactivation, it's not clear what do you mean. A window can be activated and deactivated; and this...
15 Sep 2014 by BillWoodruff
You are creating a new instance of Form1 every time the user clicks button2 in Form2; my guess is that you are never making that instance visible by calling 'Show on it.If Form2 is your Main Form, and creates Form1, then create one instance of Form1: in the Load EventHandler for Form2, make...
24 Sep 2014 by Gihan Liyanage
Use This Query ,SELECT C.student_id, C.studentname, M.Guardian_NameFROM TableStudent C OUTER APPLY ( SELECT TOP 1 * FROM TableGuardian M WHERE M.student_id = C.student_id ) mSince you want to get any guardian I use Top...
7 Oct 2014 by PIEBALDconsult
How about something like:string _lote = @"\LOT_{0:0000}";string x = System.String.Format ( _lote , 11 ) ;
14 Oct 2014 by Samatha Reddy G
Hi once try this codei created enum and class which is having two properties public enum projectstates { projectstate1 = 1, projectstate2 = 2, projectstate3 = 3, projectstate4 = 4 } public class projectcounterentities { ...
15 Oct 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Quote:for example a drop down for city and a drop down for province ?This is very simple. Two tables that's it.1. City - CityId, CityName2. Province - ProvinceId, FK_CityId, ProvinceNameWhile binding DropDownList for City, directly bind from City Table. The DropDownList for Province...
15 Oct 2014 by User 11060979
A self referencing table is a table which has a field which is defined as foreign key to the same table's primary key.CREATE TABLE DBREGISTRY( ID INTEGER, PARENT INTEGER, // PARENT references ID of table DBREGISTRY DESCRIPTION CHAR(30), INTVALUE INTEGER, ...
30 Oct 2014 by User 11060979
A pragmatic Approach :)If I really understand your question in the right way you like to make a Matrix with 1024 rows filled with lines having 10 columns which should contain only '1' or '0'.That means every pattern for binary representation will be there in your 1024 rows, because 2^10...