Click here to Skip to main content
15,893,508 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 

29 Dec 2010 by #realJSOP
A HashTable collection already prevents you from adding duplicate entries. What do you actually want to do?EDIT =============="Custom" in what way? Extra functionality? If so, just write derive a new class from HashTable, and add tyhe functionality you want. You could also just write...
20 Mar 2011 by #realJSOP
What you should do is create a set of custom events that the form can subscribe to, make the other classes post events, and then the form can subscribe to them. That way, your classes don't need to know anything about the UI component that uses them. All it has to do is post events, and if...
10 Oct 2011 by #realJSOP
Create a user control that loads the images and displays them. Then you can just give the control a directory name that contains the files, and let it do the work for you behind the scense, thus uncluttering your form code.public class MyControl : Control{ private List images = new...
15 Oct 2014 by #realJSOP
Retrieve certificates from the system certificate store
27 Oct 2014 by #realJSOP
Extension method to determine fiscal date
17 Oct 2016 by #realJSOP
The only real way to add XML comments to your code is to do it manually. There is a helper extension available for Visual Studio, called GhostDoc. It helps ease the pain a little.Of course, you could write an application to do it for you, but it would take a lot less time manually commenting...
11 Jan 2017 by #realJSOP
I tried it mostly your way and it took 39 seconds. Granted, I don't know the contents of your Stopwatch class, but all mine does is return a TimeSpan when I call my ElapsedTime method. I'm also making only one call to Console.Writeline with a string.Concatendated value. public class...
11 Jan 2017 by #realJSOP
Out of curiosity, I tried a multi-threaded approach running a single app. This too 47 seconds.static void Main(string[] args){ string str = Console.ReadLine(); if (str == "start") { StopWatch sw = new StopWatch(); sw.Start(); ...
11 Jan 2017 by #realJSOP
And finally, I wondered if sharing the same stopwatch might be causing some sort of self-induced delays, so I did this, which resulted in about 49 seconds of elapsed timed.static void Main(string[] args){ string str = Console.ReadLine(); if (str == "start") { ...
11 Jan 2017 by #realJSOP
My final solution - execution time is 0.002 seconds (I would call that "negligible" as far as elapsed time is concerned):static void Main(string[] args){ string str = Console.ReadLine().ToLower(); if (str.Contains("start")) { StopWatch sw = new StopWatch(); ...
9 Jul 2018 by #realJSOP
Try it this way: SqlConnection conn = null; SqlCommand cmd = null; SqlDataAdapter adapter = null; DataSet dataset = null; DataTable dataTable = null; try { using (conn = new SqlConnection("connection string")) { conn.Open(); using (cmd =...
10 Jun 2019 by #realJSOP
It sounds like you're tryitg to perform "live" updates without having to stop the service and restart. 0) One alternative is to have the service monitor the install folder for changes to referenced DLLs, and have it restart itself when it detects a change.This would eliminate the need to load...
30 Aug 2015 by $ultaNn
I have a tree view which i am populating from active directory i am trying to implement search in tree view , its returning null while its already fill with Active directory data TreeNode node = TreeView1.FindNode("Txt.Text");
7 Mar 2017 by $ultaNn
I can get pdf to browser , i want it in iframe with out using generic handler byte[] bytes = (byte[])GetData("SELECT * FROM [CME_Attachment] where ID = '" + ActID + "'").Rows[0]["Attachment"]; string name = name.pdf; int FileSize =...
20 Sep 2017 by $ultaNn
I am getting this error after i remove update panel from the page . Cannot unregister UpdatePanel with ID 'UpdatePanel1' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported....
12 Aug 2018 by $ultaNn
Error while using NextResult fuction with datareader cannot get second table result and error on second NextResult line " invalid attempt to call nextresult when reader is closed " using (SqlConnection myCon = DBCon) { try { string Qry = @"SELECT...
14 Aug 2014 by -Dr_X-
Set the ValidateViewState="false" within the header of the .aspx page.
17 Mar 2015 by .net bigner
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Data.SqlClient;using System.Drawing;namespace logindemo{ public partial class Welcometo :...
18 Mar 2015 by .net bigner
An exception of type 'System.NullReferenceException' occurred in logindemo.dll but was not handled in user codeAdditional information: Object reference not set to an instance of an object
18 May 2015 by .net bigner
namespace tableshow.Controllers{ public class TableShowController : Controller { private TableShowEntities db = new TableShowEntities(); public ActionResult show() { ViewBag.TableShowsData = db.TableShows.ToList(); return...
14 Nov 2014 by .Net Jim
Check this out...Faster MS Excel Reading using Office Interop Assemblies[^]
10 Jan 2015 by .Net Jim
There are a variety of ways to do this. That said there are a few key questions to shape your choices. First, can your users learn to import the xml into Excel? Excel has been able to import xml for over a decade. The key to doing this successfully is to avoid attributes in xml. Just name...
27 Sep 2016 by .Net Jim
Entity Framework 6 no longer supports wizard items. You are expected to use NuGet instead, then work entirely manually. Bottom line...used entity framework without the data source. Do in page load or other page event and bind to collection coming back or load collection into Datatable or...
24 Oct 2020 by .Net Perfect Dev
Hello, I have an xml document
18 Sep 2014 by /\jmot
try thispage_load(){ if(Session["userLogged"]=="") // check for the session { response.redirect("loginpage") }}
18 Sep 2014 by /\jmot
i used the html select.. trying to get it as dropdown list like this.. DropDownList ddlSerialNo =...
25 Nov 2014 by /\jmot
another way...radioButton1.CheckedChanged += new EventHandler(radioButtons_CheckedChanged);radioButton2.CheckedChanged += new EventHandler(radioButtons_CheckedChanged);....private void radioButtons_CheckedChanged (object sender, EventArgs e){ RadioButton radioButton =...
26 Nov 2014 by /\jmot
Another way..foreach (ListViewItem item in listView1.Items){ String abc = Convert.ToString(item.SubItems[1].Text);//etc etc }
27 Nov 2014 by /\jmot
Your code'll not display any error but the Problem is YYYY and SS is not the valid Date time Formatting string so it'll not give you the actual result.you have to use yyyy instead of YYYY and ss instead of SS.See here http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx[^]
1 Dec 2014 by /\jmot
try these..SELECT Sum(DateDiff(minute, 0, Opt)) As [TotalMinutes], Convert(varchar(5), Sum(DateDiff(minute, 0, Opt)+1) / 60) + ' hours ' + Convert(char(2), Sum(DateDiff(minute, 0, Opt)+1) % 60) + ' minutes' As [Description]FROM ...
5 Dec 2014 by /\jmot
Search here..https://www.google.co.in/search?q=encryption+in+asp.net+c%23+using+aes&oq=encryption+in+asp.net+c%23+using+aes&gs_l=serp.3...264136.271321.0.277209.15.14.0.0.0.1.210.1527.0j8j2.10.0.msedr...0...1c.1.58.serp..8.7.1055.MbQ1xtgujJU[^]See...
5 Dec 2014 by /\jmot
string path = "C:\\stagelist.txt"; string extension = Path.GetExtension(path); string filename = Path.GetFileName(path); string filenameNoExtension = Path.GetFileNameWithoutExtension(path); string root =...
8 Dec 2014 by /\jmot
use..SpellNumber.dll to convert amount in Works..See here..Convert Amount in Words and Separate Amount with comma in Bangladeshi Currency Format using C#.NET[^]
9 Dec 2014 by /\jmot
See for more Explanation..http://stackoverflow.com/questions/7074/whats-the-difference-between-string-and-string[^]
14 Dec 2014 by /\jmot
See..http://www.codersrevolution.com/blog/SQL-Server-How-Many-WorkWeek-Days-In-Date-Range[^]
16 Dec 2014 by /\jmot
See..http://docs.sencha.com/extjs/5.1/components/forms.html[^]https://www.packtpub.com/books/content/login-page-using-ext-js[^]
16 Dec 2014 by /\jmot
its for the..RemainingLabel.Text = remainXp.ToString("N");PercentageLabel.Text = percentage.ToString("p");See this..You'll understand.http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx[^]
23 Dec 2014 by /\jmot
what about this..https://www.google.co.in/search?biw=1366&bih=667&q=sample+asp.net+project+with+source+code&oq=sample+asp.net+project+with+source+code&gs_l=serp.12...0.0.0.3668.0.0.0.0.0.0.0.0..0.0.msedr...0...1c..60.serp..0.0.0.n2LReAT8p7g[^]
2 Feb 2015 by /\jmot
You will need to modify two properties in the .rpt files:Build Action is set to "Embedded Resource" by default. Change it to "Content".Copy to Output is set to "Do not copy" by default. Change it to "Copy always".Rebuild, Build deployment package and Publish....
2 Feb 2015 by /\jmot
Ref.http://www.dotnetwindow.com/2014/04/WPF-Insert-Update-Delete-Operation-on-Datagrid.html[^]http://www.dotnetcurry.com/showarticle.aspx?ID=566[^]http://www.dotnetcurry.com/showarticle.aspx?ID=563[^]https://gsselle.wordpress.com/2013/05/26/wpf-datagrid-update-insert-and-delete-operations...
4 Feb 2015 by /\jmot
if (mySQLConnection.State != ConnectionState.Open){ mySQLConnection.Close(); mySQLConnection.Open();}see the...
7 Feb 2015 by /\jmot
use..string rootFolderPath = @"C:\\SomeFolder\\AnotherFolder\\FolderCOntainingThingsToDelete";string filesToDelete = @"*DeleteMe*.doc"; // Only delete DOC files containing "DeleteMe" in their filenamesstring[] fileList = System.IO.Directory.GetFiles(rootFolderPath,...
9 Feb 2015 by /\jmot
use DirectoryInfo.Name Property.string str = @"\sub1\sub2\sub3";string dirName = new DirectoryInfo(str).Name;ref.https://msdn.microsoft.com/en-us/library/system.io.directoryinfo.name.aspx[^]http://stackoverflow.com/questions/5229292/get-folder-name-from-full-file-path-c-asp-net[^]
10 Feb 2015 by /\jmot
public class CheckBoxItem{ public string Code { get; set; } public bool IsChecked { get; set; } public string Label {get;set;}}razor: @Html.HiddenFor(x => x.Code) @Html.CheckBoxFor(x => x.IsChecked)@Html.LabelFor(x => x.IsChecked,...
10 Feb 2015 by /\jmot
Try..SELECT *FROM MDT_Organisation_MasterORDER BY CAse When Organisation_ShortCode = 'Mewaholeo' THEN '1'Else Organisation_ShortCode ascref here.http://sqlandme.com/2013/11/18/sql-server-custom-sorting-in-order-by-clause/[^]
12 Mar 2015 by /\jmot
Use CONTAINS()e.g..SqlQry= Select * from table_name where column_Name not in(val1,val2,val3,..)List liS=new List;liS.add(val1);liS.add(val2);...LinqQuery:from o in context.table_name where !liS.Contains(column_Name) select o;
13 Mar 2015 by /\jmot
you acn use another table to hold on the globel id.table_globel_id@id as bigintwhenever inserting to any table use ID from this tablelike: select isnull(id,0) from table_globel_idand whenever complitiong the sql query/transaction increase the value of the id in...
28 Apr 2015 by 01sathish
Hi,I'm calling a Stored Procedure say 'GetUserDetails' which retrieves say 3 rows with 3 columns [3X3] with SqlCommand and this is stored in to a DataSet.Now I wanted to loop through each row from the DataSet and write each row to a separate text file, I mean the final outcome should...
3 Nov 2015 by 12045649
Hello Every One..I want to write f11 button functionality in my asp button ...Can u please help me in that.
16 Nov 2015 by 12045649
Hello friends, i am using HtmlEditorExtender ajax control .Here the problem i want toolbar at the bottom of the text box..Could it can be done..?
22 Apr 2014 by 123456789igor
Hello, I'm use AForge framework and i get image capture from webcam, then i want to send this image from server to client. But the problem consists of that i get the bitmap variable, which gets in event, after executing method AcceptTcpClientAsync and bitmap variable is null. How to get image...
30 Apr 2014 by 123456789igor
Hello, i try to write a simple asynchronous client/server apps. I know how do it using callback, but i want to invistigate how write client+server using await/async and c# 5.0. Please, help me. It should be simple. Only connect and transfer some bytes.I know that this can be done using...
1 May 2014 by 123456789igor
Connect success. But how to send bytes, i don't knowprivate readonly Socket _server; public ServerSocket(IPAddress ipAddress, int port) { _server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _server.Bind(new...
1 May 2014 by 123456789igor
now server can send to client array of byte. But client recieved only 1 iteration. How i can do, that if client connected then it always recieve information from server?Server:public ServerSocket(IPAddress ipAddress, int port) { _server = new...
14 Jan 2015 by 123456789igor
Hello, I've finished with client-server video streaming. And now I want to do this using peer to peer. Please advise how to start. I've found and read only theory. But I want to find any finished project with p2p. Maybe someone can give some links on finished project?
21 Sep 2014 by 123456789shaik
Sir/Madam,Please tell me "DO While loop" will support in dotnet or not either i c# or asp.netPlease tell me the answerI got this question in written test
23 Nov 2014 by 123456789shaik
I have two file upload controls in Windows application How can I save it to database one control for >>Image2 Control for >>> Idproof Imageplease help me any body...
26 Nov 2014 by 123456789shaik
hii need to search data in datagrid view with different fields i am geting error for that syntax error at keyword WHEREbut it is executing for single field but i need two more field to search with one textboxplease help me...my code is hereprivate void button1_Click(object...
26 Jul 2014 by 1Future
Hello All, To begin with, I am an intermediate C# Developer (Windows Forms). I am well aware of this site and I am a regular user and when ever I ask a question I usually do show my working or code.Now, I have have just been introduced to MVC and C#.Net in which I am completely a...
2 Jun 2015 by 1Future
Hi All,so , I have a method in my controller like so:[HttpPost]public ActionResult Mycontroller(string RefNumber){ CustomerEntities custObj = new CustomerEntities(); var customer = from m in custObj.CustomerTbl select m; if (!string.IsNullOrEmpty(RefNumber)){ ...
11 Oct 2017 by 1Future
Hi, I have a partial view with another partial view. When i try to post the data from the partial view to Action method nothing happens.Even when i put a break point in the action method nothing happens .. it doesn't hit the break point. is there anything i'm doing wrong below? or could someone...
31 Oct 2014 by 2011999
There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "xyz.Doman", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the...
31 Oct 2014 by 2011999
The type arguments for method 'System.Web.Mvc.Html.InputExtensions.TextBoxFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
25 Apr 2015 by 23741
You can't go wrong with: Programming Microsoft ASP.NET MVC (3rd Edition) (Developer Reference) Paperback – February 25, 2014by Dino Esposito...
14 Oct 2015 by 23741
To make things more efficient, you might reconsider saving the file name as follows:string fileName = Guid.NewGuid().ToString() + "-" + Path.GetFileName(PostedFile.FileName);That way, to determine the original uploaded file name later, all you need is the substring starting at the end of...
10 Dec 2014 by 24983
Hi, How to get Internet speed in c#.Net?Please le ne know if anybody knows. Thanks in advance...
17 Dec 2014 by 24983
Hi, How to get system idle duration in c#?
8 Jan 2015 by 24983
Hi, I want to get the System Idle Time in c#.net? After system goes to Idle mode without use mouse or keys then I want to get the IdleDuration, LastInputTime and CurrentInputTime both of these fields are insert every 5 mins in Sqlserver table.Please help me,Thanks in Advance
20 Jan 2015 by 24983
Hi Now I get the list of running applications using c# windows App. How to get worked Hours for application using c#.net? For Example I have worked 8 hours a day then 4hours for Visual studio and 4 hours for Excelsheet. I want to get these information in C#.net windows...
12 Feb 2015 by 24983
Hi, I have developed C# windows applcation tried to run exe in Laptop then its blocked by Antivirus software. I want to run the applciation as a background and its for monitor.How to solve this issues?Thanks in advance
12 Feb 2015 by 24983
Hi, Actually I am trying to get History from Firefox using C#. then I added dll as reference in my projects. THen I get the error "Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"below my...
22 Feb 2015 by 24983
Hi, I am biginner to learn xamarin? How to create Xamarin Visual Studio C#?Please if you have any materials or videos please send me.
9 Oct 2014 by 2irfanshaikh
Please check the below code.. for you reference....Button cmd = new Button("Click");cmd.Click += new EventHandler(button1_Click);....private void button1_Click(object sender, System.EventArgs e){Message.Show("Hi");}Please refer below...
9 Oct 2014 by 2irfanshaikh
use reCaptcha this is very good and easy to implement. also sample code is providedhttps://developers.google.com/recaptcha/docs/aspnet[^]It will work and only with local host and live registered domain which are exposed on internet
18 Apr 2015 by 2toetommy
I have a local sql DB. I am trying to pull form table HomePage and return and use as a string. This is for a simple webBrowser as a learning project. I think I am close but just not sure.This snippet is the Home button_click event. private void button5_Click(object sender, EventArgs...
18 Apr 2015 by 2toetommy
Thank you for clearing a lot of that up. Makes much more sense that way. I tryed this that way and I get this. http://pastebin.com/ysdKCTtg[^]Here is what I changed my code to (same as yours i believe)Quote: private void...
29 Jun 2015 by 3DC#
Hey there, long time since i asked a question. I want to display all validation-errors and disable two buttons addicted from the validation-error.Background: I have a table where the user can add and delete rows. The primerykey (Number)shall be validated and if there is an error the...
15 Aug 2014 by 4L4K1
when I want to show a dataGridView with backgroundWorker I call showDGV("mydataGridViewname") in bw_dowork function . delegate void Dstr(string s); public void showDGV(string s) { if (Controls[s].InvokeRequired) { Dstr h = new...
17 Aug 2014 by 4L4K1
I learned how to use mplayer in C# by this article : Simple Mplayer Front End in C#when I use -ss 25 -endpos 10 mplayer should displays ten second from second 25 until the second 35but it just displays 5 last seconds( it displays from 30 until 35)i think because of the video is large...
20 Aug 2014 by 4L4K1
I use this code to get all files name in a folder. rootFolder="D:\\rootFolder\\";var videofilenames = Directory .GetFiles(rootFolder, "*.*", SearchOption.AllDirectories) .Select(s => Path.GetFileName(s)) .Where(s =>s.EndsWith(".mp4") ||...
20 Aug 2014 by 4L4K1
rootFolder="D:\\rootFolder\\...
26 Aug 2014 by 4L4K1
I used mplayer2.exe to play video in C# winform app.How do I play subtitle with mplayer2.exe in the slave mode?
7 Nov 2014 by 4L4K1
prevent your program to become cracked ! what files should become obfuscated ?thank you in advance.
11 Nov 2014 by 4L4K1
how to backup and restor some records of a table in sql database by C#?(some records) I mean to select some record and make a backup file of that records.then restor that records .in restoring i preffer to click on file and automatically records backs up to the table of database.thank...
11 Nov 2014 by 4L4K1
how to backup and restor a table in sql database by C#?
15 Nov 2014 by 4L4K1
i have two sql databases that are created in a same way and they are in the same path.i can open one but in opening another one i got this error:An attempt to attach an auto-named database for file xxx.mdf failed. A database with the same name exists, or specified file cannot be opened, or...
15 Nov 2014 by 4L4K1
the problem was this :mdf file was not included in project.(i fond it in Solution Explorer windows)i used relative path (AttachDbFilename=|DataDirectory|...)in connection string and it makes problem.
21 Nov 2014 by 4L4K1
How to clone a sql database (without data) by C# programmatically?
25 Nov 2014 by 4L4K1
there is a C# formapp .it creates and uses and delete files.in deleting files i do not know which object or process is using them to dispose them .forcing garbage collection doesn't help too.what would you do if you had this problem?thank you in advance.
28 Nov 2014 by 4L4K1
how to pass a list element by ref ? private void Form1_Load(object sender, EventArgs e) { List mylist = new List(); mylist.Add("hi how are you?"); sara(ref mylist[0]);//there is errore } public void sara(ref...
12 Dec 2014 by 4L4K1
i know how to play video by mplayer in C# formapp and i want to know ...how to make it fullscreen?how to display subtitle for any language?
13 Dec 2014 by 4L4K1
how to drag a file from windows explorer to C# form and read its path?i used this code but events do not arised! private void Form1_Load(object sender, EventArgs e) { this.AllowDrop = true; this.DragEnter +=new DragEventHandler (Form1_DragEnter);...
14 Dec 2014 by 4L4K1
I want 1).bak files that is created by my program have the icon of it.2)by clicking on .bak files restore begins.
24 Mar 2015 by 4L4K1
how do I drag and drop a file from windows explorer to a panel and read its path?according to this article I did what it said.but no event(Form1_DragDrop and Form1_DragEnter) fire.
5 Jul 2015 by 4L4K1
I can send and receive data between two formapp.using System;using System.Net.Sockets;using System.Text;using System.Windows.Forms;namespace Client{ public partial class Form1 : Form { public Form1() { InitializeComponent(); ...
1 Nov 2014 by 9000605667
how many ways we can do the asschronus calls in .net
2 Apr 2015 by 9000605667
I have a class A with 3 methods M1,M2,M3.Class B is inherited from Class A & Class C is inherited from Class B.Now all the methods in Class A are accessible for Class B & Class C.Now i want to restrict 1)M1 & M2 of Class A for Class B2)M3 for Class C .How can i do this.
6 Jul 2015 by 9000605667
this solution will use full when my front end is in MVC. But my Front end is Angular JS. So it will not resolve the issue. But i fix this issue by changing the access specifiers of Trip in Layover class from public to private.Thanks for your solution..
9 Feb 2015 by @shok kumar mishra
I want to store logedin session state in SQL Server and check whether he session is active or not.Please help me to find the solutions.Thanks in Advance