Click here to Skip to main content
15,890,512 members
Everything / Programming Languages / C# 6.0

C# 6.0

C#6.0

Great Reads

by Qwertie
It has 41 features in about 1000 lines of code* - but only 3 lines are needed to parse the expressions you type in. Uses WinForms, BackgroundWorker, GDI+ and LES.
by Ratish Philip
The next version of the useful WPF controls is here
by phil.o
This article describes the building of Markov Chains and their use for generating random names or words.
by Kenneth Haugland
How to connect hot observables to Rx

Latest Articles

by Dave Elliott
A series of 6 articles to provide you with a boilerplate guide to create Source Generators.
by Dave Elliott
A series of 6 articles to provide you with a boilerplate guide to create Source Generators.
by Dave Elliott
A series of 6 articles to provide you with a boilerplate guide to create Source Generators.
by Dave Elliott
A series of 6 articles to provide you with a boilerplate guide to create Source Generators.

All Articles

Sort by Updated

C# 6.0 

18 Oct 2016 by #realJSOP
private static void EnsureVisibleRow(DataGridView view, int rowToShow){ if (rowToShow >= 0 && rowToShow
15 Mar 2018 by #realJSOP
Simply get the distance between two points, and see if it's within the desired radius. If the Google Maps API doesn't have a function for that (and it would honestly surprise me if it didn't), you can use the class in this article to determine the distance between two GPS points. A Handy GPS...
1 Jun 2018 by #realJSOP
0) As pointed out by Richard, part of your problem is that you need an else condition to remove the datetime. 1) The other part of your problem is that you have no way of knowing what to remove because you're not storing the datetime (that was inserted) in a variable. How can you possibly...
5 Nov 2018 by #realJSOP
Create a static class that contains the desired user data. When the user logs in, capture the desired user data into your static class, and you can still return a bool from your login method.
6 Nov 2018 by #realJSOP
should i be doing this with data binding because this is WPF? Yes.
1 Dec 2018 by #realJSOP
I know - it's unfortunate that you have to actually write some code, but that's how it goes. Put a try/catch block around the code that's attempting to insert the new user, and in the catch part, show a message box that shows "User name already exists.", and let that be that. At the same time.
2 Dec 2018 by #realJSOP
I do it this way: SqlConnection conn = null; SqlCommand cmd = null; try { using (conn = new SqlConnection("blah blah")) { conn.Open(); using (cmd = new SqlCommand(...)) { //... your code } } } catch (Exception ex) { //... do something...
3 Apr 2019 by #realJSOP
0) Your linq query makes no sense because EVERY day is between the first/last day of its month. Maybe you meant to compare just the month? (We can't see what the vars LastDayofMonth and FirstDayOfMonth are, but I assumed they're a datetime.) Maybe better names would be StartDate and EndDate? 1)...
4 Apr 2019 by #realJSOP
Instead of trying to "find it on the forum and on the internet", try taking notes in class, and then referring back to them when it's time to do your homework.
4 Apr 2019 by #realJSOP
Use LinqwToXML to load the document, add your new data, and save the document. Easy peazy lemon squeezy.
24 Apr 2019 by #realJSOP
You cabn't do razor pages without controllers. The db work is done from the controller - not the view. The view simply presents the data to the user in the form of appropriate markup. Once data has been retrieved from the db, put it into a session var if you don't want to keep making the round...
7 May 2019 by #realJSOP
This website is blocked where I work, but look here: Shufti Pro API Source Code Samples | ProgrammableWeb[^] BTW, I did a google search to find that link. I heard that google searches were recently made free of charge, so you can do it, too...
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...
18 Jul 2019 by #realJSOP
If it were me, I'd send HTTP requests and evaluate the un-rendered response instead of waiting for a web page to render. You could try putting each request in a thread.
31 Oct 2019 by #realJSOP
That's a poor design. Make the user click a "Change Password" button to change the password. When the button is clicked, display a new form for that purpose. If you want to be clever, you can use a borderless non-movable non-resizable form that's centered on the parent, and it won't look like...
10 Jun 2022 by #realJSOP
If you insist on wanting to "change the property name (which I personally think is a TERRIBLE idea), just create a couple of getter/setter extension method that does what you want: public static int MyRenamedProperty(this MyObject obj) { ...
2 Apr 2021 by #realJSOP
Try this: ((DataTable)dgv.DataSource.ToTable()).Clone(); Personally, I would never work directly with a DataTable. All of my database stuff is handled through a DAL and is moved to/from model entities.
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....
3 Jan 2018 by $ultaNn
how can i use transaction code in below code for multiple query private SqlConnection DBCon { get { return new SqlConnection(ConfigurationManager.ConnectionStrings[" "].ConnectionString); } } protected DataTable ExecuteQry(string Qry) { DataTable dt = new...
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...
13 Feb 2023 by $ultaNn
Dear i ave followed steps given in this Link when I debug the application, I am getting Error This site can’t be reached What I have tried:
24 Oct 2020 by .Net Perfect Dev
Hello, I have an xml document
10 Nov 2018 by 11917640 Member
Int64 localp = RerturnLocalPlayer();
11 Oct 2015 by 12045649
Hello friends.. i am doing dragging and dropping with in repeater control(3 repeaters control side by side)..within the repeater i kept label ..getting the label text from database(binding from database)..Now the problem is while dragging the label i want to know the label...
12 Oct 2015 by 12045649
Hi friends...I am getting error while installing crystal report from http://www.aspsnippets.com/Articles/Download-Crystal-Reports-for-Visual-Studio-2012.aspx[^]Please help me for this.?
13 Oct 2015 by 12045649
Hello friends, I am doing report using sql data..in my website(report viewer in asp.net)..I want to change the colour of bar and pie diagram ..Because in my website it is not looking good..So i want to change the colour But It is not coming ..Can any one help me with this please..
13 Oct 2015 by 12045649
We Can Use custom palette colour in properties..After Right click the chart..
13 Oct 2015 by 12045649
Hello Friends.. .. getting local time using javascrit..Here Problem is i am getting the time but in var variable ..I am unable to send to database..Can any one help me how to convert var variable to datetime format..?
18 Oct 2015 by 12045649
Hello friends,..var dt = new Date(); var a = new Date(dt).toLocaleString(); alert(a);I used above code ...here i wanted the var variable to int variable because i wanted to send it to database(which is in datetime format)..Can anybody help me ..?
19 Oct 2015 by 12045649
Hello friends, source Code: function getdates() { var today = new Date(); // ...
26 Oct 2015 by 12045649
Hello friends..I am using google line chart in my application .. i have done with it..But i want to change color of the lines..Can u any help me how to change the color of a lines..My code .cs:public partial class _Default : System.Web.UI.Page{ StringBuilder str = new...
27 Oct 2015 by 12045649
Hello Friends I got the solution for above problem :getting data from database and creating google line chart in asp.net :source code :Multi series Line chart using Google...
28 Oct 2015 by 12045649
I want to make gridview having functionality of column drag and drop Means column can be move ex. If we drag 1st column on 3rd column it will drop on 3rd position any suggestion or help please Thanks
25 Jul 2018 by 1hakankaraca
I am doing one disk management application. I can take out the discs that have been created. The main problem is to see what has not been created. And to make them unit and shape. I do not want to use Windows's disk management application. What should I do for this? What I do is almost identical...
19 Feb 2016 by 4L4K1
Hi I know how to use mplayer in C# form application according to this link.i wanna know how to use mplayer in asp.net web pages.i want a player on web page that I can tell it to play a part of a larger video for example from 0:1:10 to 0:3:20 .thank you in advance. any help is...
5 May 2019 by 4L4K1
why this wierd convert double to string happens? I use win 8.1 ,visual studio 2019 in laptop it is wierd. i use win 10 , visual studio 2019 in PC and it is ok. What I have tried: double d=1.2; string sWierd =""+d;//s=1/2 string sOk=d.ToString();//s=1.2 //both are not "1.2" for me so that...
30 Sep 2017 by 855
i want to set image to leaf node only, but it appears that the non-leaf nodes are set automatically. What I have tried: tv.ImageList = images List Nodes = tv.GetAllTreeNodes().ToList(); foreach (TreeNode tn in Nodes) { if...
9 Oct 2017 by 855
VB.NET i want to delete a folder using below code. Normally it works but when the testfolder is open, below code got an exception. My.Computer.FileSystem.DeleteDirectory("testfolder", FileIO.DeleteDirectoryOption.DeleteAllContents) is there any way to delete the folder even when the folder...
9 Oct 2017 by 855
public class A { public string prop { get{ ...some logic...; } } public string method() { string p = do something calculation using prop. return p; } } public class B { // i would like to override property prop, // so when i call B.method...
2 Nov 2018 by _ProgProg_
Dears, I 've a situation here in uploading multiple files from multiple controls in asp.net mvc. How can i differentiate (grouping) between files of each file upload controls? In HTML: Here is the uploaders:
20 Nov 2023 by A Belal
I get tokenKey from path https://localhost:7107/api/login And when i try to test token and get data from Path https://localhost:7107/api/Values the token work good and data comes well but when i remove token the data continue come and...
10 Feb 2021 by aakar
Hi, I have a legacy web application which accepts user input from textboxes. In one of the screens where user can add new records to the database, need to prevent SQL injection by making not much changes to existing code. Existing code is as...
15 Feb 2016 by Aaron Amberman
Advanced custom logical and visual tree walking methods
1 Jun 2017 by aashish tyagi
How to create password and expire date protected PDF in c# ,if any buddy idea please help me What I have tried: i have created pdf with password protected but we require pdf password and expire date protected
29 Sep 2016 by Abani_samal
I have a wpf datagrid. I have 10 columns in that. I need to show a summary row at the end of the data grid. It should show record count of each column at the end of each column in the data grid. I need something like below. Column1 Column2 Column3 test 1 ...
4 Sep 2016 by abdul subhan mohammed
Hi Guys,I want to convert javascript date to c#.In my asp.net web application, i'm storing the values in Hiddenfields.This hdn.value then, i'm trying to convert to DateTime in C#.But getting the error as "String was not is proper format"eg: date from javascript:...
6 Sep 2016 by abdul subhan mohammed
Hi guys,I have fullCalendar control on my asp.net page.and I have dates values stored in SQL SERVER DataBase.For this I wrote stored procedure to get values.Now, I want to fill these values(dates) in the FullCalendar...What I have tried:which method I have to use to fill...
6 Sep 2016 by abdul subhan mohammed
C# code: public object SessionScheduleDates { get { string output=""; if (Session != null) { string input = Session.ScheduleDates; output = "[" + "\"" +...
23 Jul 2018 by Abhijeet P Singh
I want to detect the user input any where in windows and want to replace it with my custom value. For now I am using hooks to detect the key press but I am not able to change the key value: as like if user typed "Hello " in notepad the it want to replace it with "Hey! there..." What I have...
12 Oct 2015 by Abhinav S
Regular Expression Example: Changing Date Formats[^] is a good example that uses regular expressions and the Regex.Replace method to replace dates from one format into another.
12 Oct 2015 by Abhinav S
TryConverting to TIFF[^]C# PDF - Convert PDF to TIFF in C#.NET[^]
7 Jun 2016 by Abrar Kazi
Required Quantity : 530 Buffer Qty allowed is : -5% to +10% of Required Qty which becomes : 583 for +10% 503.5 for -5% BATCH | QTYB1 | 510B2 | 500B3 | 15B4 | 12B5 | 10So here i want all the combinations that fall between 503.5 & 583.Eg :...
9 Aug 2016 by Abrar Kazi
string Batches = ",,H104001002,H104001003,H104001004,H104001005";I have this string and i have to remove "H104001002" from the above string in ASP.Net C#.What I have tried:I was thinking to use Contains to find the string and Replace to replace it with ""
7 Oct 2016 by Abuamer
i have 2 forms > form1 and form2> form1 hs one textbox and 2 buttons >when you click button1 it save the textbox value in the combobox. when you click button2 it show form2 which has acombobox that retrieves data from combobox1 in form1> but it is not workingWhat I have tried:thats...
29 Oct 2018 by Abuamer
i am developing aquery that Update two Tables at the Same Time with user_defined_Table_types (Tbl_addition_Store and Tbl_item_Journals) tbl_addition_store (add_id,date,product_id,Supplier_id,Quanty,price,value) Tbl_Journals(journal_id,add_id,date,product_id,Supplier_id,Quanty,price,value) i...
5 Nov 2018 by Abuamer
i have datagridview named Dgv_Invoice connected with database .when i call data into 7th column in the first row i want to copy this value into the second row cell 7 from the above cell .and the third row cell alse from the above row cell. but it works for all datagridview> i want only to copy...
2 Dec 2018 by Abuamer
i have two datagridviews(first one called Dgv_Invoice,and 2nd called dgv_costCenter) the data in the second datagridview(dgv_costCenter) was item name price quantity value customerid keyboard 20 10 200 1 mouse 10 10 100 2 monitor 200 2 ...
21 Dec 2018 by Abuamer
i have to forms ... the first one is form_Items_Transaction with datagridview (Dgv_transactions) and the second one is Form_Search_Items with datagridview(Dgv_Search)... i have fill dgv_transactions with datatable.so i want to fill column 7 from dgv_transaction with column 1 in dgv_Search with...
24 Feb 2019 by Abuamer
i have a datagridview named datagridview1 . i want to select multiple images from any folder and put the inside my datagridview. i have successfully added then inside my datgridview1 .but the problem is how could i save those images into my sqlserver database . can any one help me What I...
20 Mar 2019 by Abuamer
i have a desktop application which i want to use to upload Files into my google drive.i created a Method To Upload the file > i call the method in the button click. but the problem is the code doesn't work. can any one help What I have tried: private void btnUpload_Click(object sender,...
21 Mar 2019 by Abuamer
i have c# desktop application which i created to store images inside SQL server database ,Based on customer's desire .the problem is the code work's correctly and the images stored with different ways, but with a big size,so i tried to resize images before saving then,but my method to resize...
17 May 2019 by Abuamer
i want to loop through my win form Application to set my security roles on it. i have aribboncontrol1 which has six barbuttunItems .(barbuttunSave,barButtunEdit,barButtunDelete,barButtunNew,barButtunPrint,barButtunExit) i want to make only barbuttunSave and barButtunPrint active(enabled=true)...
8 Oct 2019 by Abuamer
Iam New In Entity-framework...i created Windows Apllication in visual studio 2019 iam using Entity-framework 6.i created DatabaseContext like that using LedgerGroup.TheLedger.Core.Entities; using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; using...
1 Mar 2021 by Abuamer
i created desktop application in accounting Field using c# and SQL Server 2014 . i have more than 36 users using my program at the same time . i already hosted my database at smarterAsp.net . my program Consists of 7 modules(Fixed Assets-...
28 May 2017 by Acha Bill
I this FacebookController [MobileAppController] [Authorize] public class FacebookController : ApiControlle private TodoUserService todoUserService; protected override void Initialize(HttpControllerContext controllerContext) { base.Initialize(controllerContext); ...
12 Oct 2021 by ADI@345
i am making an eccomerce website where i have store data in cart using cookie. I am easily store string variable but problem facing when storing image. What I have tried: HttpCookie userInfo = new HttpCookie("userInfo"); userInfo["image"] = Image1.ImageUrl; ...
15 Feb 2019 by aditya pewekar
Create custom HTML helper to manage Page Mode like View (Readonly) and Edit/Add (Editable)
27 Sep 2016 by Adityakumar2318
I have free domain names as codingwithpassion.tk and i want to get free hosting.Also i have developed a project in the asp.net, sqlserver. Can i upload the same?Please help.Thanks in advance.ThanksAditya KumarWhat I have tried:I tried to use so many free hosting sites...
16 Dec 2016 by Adityakumar2318
Hello Sir,I am making a project in Asp.net MVC using Entity framework and i am confused Which is better to use Html helper class or simple html control in MVC?For eg- For Textbox- I can use html helper class and simple html input textbox also.Please suggest me which one to use and...
2 May 2018 by adityarao31
Question in practice is "Create collection class called People that is a collection of person class.The items in the collection should be accessible via a string indexer that is name of person,identical to the Person.Name property. I found answer at back of book but its incomplete.That code...
2 May 2018 by adityarao31
Thanks for your reply I understood the explanation.Also understood that I don't know indexer concept. Will you please tell me what code should I write inside main function. Also just broadly tell me what is indexer and for what it is used? So that I can study it thoroughly.
9 Oct 2015 by Afzaal Ahmad Zeeshan
Sure, MSDN is here to help you in getting started to "Showing a Toast Notification in Windows 10". Remember, Windows 10 runs on Windows Runtime as the API for software development. So, do not confuse is the solution says, "Windows 8/8.1" etc. It works on Windows 10 too....
6 Nov 2015 by Afzaal Ahmad Zeeshan
To field is for the recipient, the one who receives it whereas From field is for sender, the one sends the email. SMTP servers or clients would use these parameters to generate a GUI for the client to read who sent the email or who was sent the email. In cases where you are going to send an...
10 Oct 2016 by Afzaal Ahmad Zeeshan
Good request that you are making here. Sadly, there are very less guides that take Visual Studio Code into considerations and the one that do take it into consideration talk about .NET Core applications, and not the ASP.NET applications. I am currently working on a book titled, "Considering...
16 Dec 2016 by Afzaal Ahmad Zeeshan
The answer depends upon many factors, but just a rule of thumb can be, If your data in Models requires or has some attributes defined for data validation in the forms, or the data has some special format to follow, then using HTML helpers can help in generating the dynamic UI easily. That is...
25 Feb 2017 by Afzaal Ahmad Zeeshan
And by secure what do you actually mean? Do you mean, that unauthorized access should be prevented? In that case, you need an authentication system. ASP.NET Web API already has that feature, it is called Identity.ASP.NET Identity 2.1 with ASP.NET Web API 2.2 (Accounts Management) - Part 1 -...
5 Mar 2017 by Afzaal Ahmad Zeeshan
First of all, we do not provide free code services to your demands. Secondly, the image also does not contain any navigation, just an image and a few white blocks. It does not explain anything at all. Finally, you can look for "css navigation code", and then use them in your...
11 Apr 2017 by Afzaal Ahmad Zeeshan
Although to handle the errors, you would need to use a try...catch block, whereas in this case it would be an if...else block to be used. ButtonPrev = FindViewById(Resource.Id.buttonPrev); ButtonNext = FindViewById(Resource.Id.buttonNext); TextTitle =...
7 May 2017 by Afzaal Ahmad Zeeshan
On the server, these things do not work — unless your hosting environment provides you with these paths, strHTMLContent.Append("".ToString()); There, you would need to do something like this, ...
3 Jun 2018 by Afzaal Ahmad Zeeshan
Quote: I have a scenario where I need to get data from APIs, do some calculations, save the data into database and display it on real time dashboard, there should not be much latency data synchronization. Sure, you can use ASP.NET Core as the development framework, SignalR as the sockets...
27 Sep 2018 by Afzaal Ahmad Zeeshan
In this problem of yours, a very easier way would be if there can be found some of their APIs or libraries that can let you do this. But since you do not intend to use, or perhaps the service does not expose an API, the only way to do this is using an external library that will allow you to...
7 Nov 2018 by Afzaal Ahmad Zeeshan
If you want to use C# because, then you have to leave all that pointer luxury with the C++. The core concept of C# was to enable you to have a managed environment, where you only had to write the business logic instead of having to manage the low-level memory and hardware as well. C# itself is...
22 Jun 2019 by Afzaal Ahmad Zeeshan
Please study how SMTP protocol works and how different SMTP service providers function. They do not allow, or sometimes they hide away the fact whether an account exists or not. I once worked on a project where we had to accept and receive the emails for every recipient email address (yes,...
30 Jul 2019 by Afzaal Ahmad Zeeshan
Quote: what on earth is a directory and how do I implement it , where do I implement it A folder. :facepalm: What they are saying is that you need to create a folder (directory) called "data" and store the data files (on which you will be training models) in that folder (directory). Oh, and...
1 Aug 2019 by Afzaal Ahmad Zeeshan
Quote: but it needs a lot more training That is machine learning 101 for you right there. Quote: I would literally just ask the user if the prediction was correct This does work, and will work just fine. In most production environment this is not ideal scenario as it can lead to so many serious...
2 Sep 2019 by Afzaal Ahmad Zeeshan
Quote: how upload my sql database to my client computer You do not do that. Databases are meant to be protected on the servers, behind secure firewalls and authenticated systems. Your SQL Server, MySQL and other databases are the meat of your business. You are a student, thus I am trying to...
15 Mar 2021 by aherceo
public ProductsList() { InitializeComponent(); CreateProductList(); DataTable dt = DataTableProductList(productList); // it is assumed that productList is a public variable of type List ...
20 Aug 2020 by Ahir Ajay
An error occurred while executing the command definition. See the inner exception for details. System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details....
8 Nov 2020 by Ahmed Adel
hi guys , i already make program at C# got public ip and added in table name IP that client side , i want to create other one for server side take those IP from sql table and add this ip in windows firewall to allow them , i already test with CMD...
15 Feb 2016 by Ahmed Amer Jaf
Fast n Easy Way to parse Json data
18 Dec 2016 by Ahmed Dabas
I have an c# application using Entity Framework and i create a trigger in the database fired after inserting , updating.I notice that the trigger does not fired when i insert or update using EF code, on the other side the trigger fired when i insert or update through sql serverWhat I...
22 Dec 2016 by Ahmed Dabas
I create (Human Resource) project , i use entity frame work 6 database first , and i'd like to upgrade ef version to ef core 1.1 what is the correct way to do that ?What I have tried:I don't know the correct way because i afraid to do mistake
19 Oct 2022 by Ahmed Elbaz
Just change the return type to List as follows: public static async Task> GetTempData()
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...
13 Jan 2017 by ahmed_sa
I need to build web site by .net web technology asp.net mvc USING C#But i confuse What is best for build Web site Implementation by MVCUsing Entity framework(build database and create modules automatic by EF)ORImplementing web site by using Code First ?What I have...
10 Feb 2017 by ahmed_sa
I work in web application MVC asp.net visual studio 2015How to make horizontal menu as below ?I need to add horizontal menu to my layout page as bellow :
27 Feb 2017 by ahmed_sa
I need to know are this connection string to excel is wrong or true public static string fileName = string.Format("{0}\\Book502", Directory.GetCurrentDirectory());string connection = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source={0};Mode=ReadWrite;Extended...
5 Mar 2017 by ahmed_sa
I work in visual studio 2015 asp.net mvc project i need to make image galary with circle lightreally I cannot know technique i will use(css or flash or what )it found on www.apharmu.com under green menu image galary automatic navigate every certain time can you tell...
9 Mar 2017 by ahmed_sa
I have problem in display image from access 2007 database to rdlci work in windows form c# vs2015Actually i need to display image from database to more records from access 2007but i cannotin rdlc i do as following :In RDLCdrag image control to report source...