Click here to Skip to main content
15,895,084 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 Title

C# 6.0 

4 Jun 2018 by User 4180254
Hi. I am facing strange error "the application is in break mode" when trying to debug my unit test methods. Even clicking on the link as shown in suggested actions it just disconnects and nothing happens. Suggested action links are - 1. Show Diagnostic Tools 2. Check fro running TASKS 3....
4 Jun 2018 by gael12334
Is it a Windows Form app? if so, check if the class is the first in your .cs file. You may also look at the Program.cs...
19 Dec 2016 by Member 12821924
Hello Im recieving an "}" expected error, im trying to end my main method after the public class starter. Why am i receiving this error?using System;using System.Collections.Generic;using System.Linq;using System.Data;using System.Diagnostics;using...
19 Dec 2016 by Dave Kreskowiak
Um, you tried to define an entire class inside your Main method in the Program class. You can't do that.If you really think that's the "correct placement" of this code, then you know nothing at all about C# and copied this code from somewhere and have absolutely no idea how it works.
17 Apr 2018 by Member 13771716
I am currently getting this error when trying to select a date from a drop down list, once the date is selected it should Display data in a GridView depending on the drop down list value. This is achieved using a 'Where' statement equals the value of the selected index. I understand that it is...
17 Apr 2018 by an0ther1
You need to convert the value to a DateTime value. You can use DateTime.TryParse - refer; DateTime.TryParse Method (String, DateTime) (System)[^] or DateTime.TryParse Method (String, IFormatProvider, DateTimeStyles, DateTime) (System)[^] Alternatively you can use DateTime.TryParseExact -...
14 Aug 2018 by Niranjan Vinay
If the pass the registered email id and password to login it's showing the error. There is Exception thrown in entityframework.dll and Repository.dll What I have tried: I have tried deleting .vs folder. Tried cleaning the source and rebuild it.
17 Aug 2018 by Member 13953147
private void drpProduct_SelectedIndexChanged(object sender, EventArgs e) { product_id = drpProduct.SelectedValue.ToString(); conn.Open(); cmd.Connection = conn; cmd.CommandText = "select category_name, price, mrp from product...
17 Aug 2018 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null - which...
17 Aug 2018 by Patrice T
Quote: ( Object reference not set to an instance of an object ) I am having this exception in my code.how to fix it? What happen to dr if there is no match ? dr.Read() will work only if there is at least 1 record. Note that your code only do something useful with last record, all other record...
23 May 2022 by TheBigBearNow
I been having some major issues with this, I feel like this shouldn’t be so hard but.. I am trying to be able to open a link which brings pictures to the browser to display them. I have this working. What I am trying to do is when someone opens...
19 Jul 2020 by rameshk553
Is there any SQLite DDEX provider package available for Visual studio 2019? I've tried to add ADO.NET Entity Data Model item to my WPF project, it was not listing SQLite data provider in the "Choose Data Source" dialog box to create a data...
18 Jul 2020 by Richard MacCutchan
System.Data.SQLite: Home[^]
19 Jul 2020 by Sandeep Mewara
Hi, It looks like you have used Nuget packages. They are for your application and not to provide a provider. As far I am aware (did a quick Google too), believe there is no official DDEX provider package for VS 2019. Seems you can try the...
8 Jan 2017 by mehdimughal
I have a scenario where i have a asp.net Web application and users will trigger long running jobs from my web app. Each user task will lead to multiple threaded and long running resource hungry tasks. And user will be shown logs of progress from database. I want my worker servers to be plug...
8 Jan 2017 by Ashwin. Shetty
You can use service discovery and spin up multiple processes. So from asp.net application you will check with service discovery and identify which all service are available then after getting this information you will redirect your request to service than is available to process a request (set...
23 Oct 2015 by Yaseer Mumtaz
XML input parameter to RESTful API using HttpClient and bypassing the SSL certificate
29 Apr 2019 by TheBigBearNow
I have 2 buttons but I cant bring my model to the page and click a button to determine how to set my model. I’m thinking if I can get my model in my page I’ll be able to figure out these buttons possibly. I tried bring the model like usual new { model = Model} but my model Is still null… Here...
26 Feb 2017 by Anton Angelov
Learn how to use the brand-new C# 7.0 to make your WebDriver tests even better. Utilise the power of local functions, digit separators and much more.
17 Dec 2015 by Bill Wagner
?. in C#: When properties might be null
29 Aug 2019 by Member 12132704
Hi I'm getting a scary problem The controller is invoked normally, the foreach loop works fine, call the view with a List return and the @foreach start the loop and load the registers brought from the DB, but in the last interaction it brokes. Server Error in Application '/'. Object reference...
29 Aug 2019 by jimmson
You need to debug your code and find out which property is set to NULL. That is something nobody can do for you, as we don't have any access to your data. By last "interaction" I guess you meant iteration - so I suspect the last item in Model have some property set to NULL while you trying to...
29 Aug 2019 by OriginalGriff
There is no "one solution" - this is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a method return value...
29 Aug 2019 by MadMyche
A couple of possibilities here 1. The Model being passed in is NULL 2. One of the properties of the Model.Item is NULL For the first case scenario, what I do is specifically check before I try to iterate through it@if (Model != null) { foreach (var item in Model.Where(item => item != null))...
29 Aug 2019 by Member 12132704
Probably that it must be a property setted as null, why the Model isn't null for sure, I checked debugging and the List has data. I'm using decimal properties and its not Nullable declared, it could be a problem? In Controller a do like this: var items = db.CarrinhoCompras.Where(x =>...
2 Nov 2015 by CgKumar
Hi friends,Here i have a problem, which is how to list the contents(files) of a search folder in listbox. The issue is i have many folder, each folder have many files with format .txt. I need, if i type the folder name in textbox and click the button, in the listbox shows all the files...
2 Nov 2015 by CgKumar
Hi Friends, i m settle ready the problem. i do some mistake in code. By the way thanks friends for the help. The modified code is:string[] files = Directory.GetFiles(@"\\192.123.1.16\Report\Result\"+ search, "*.txt", SearchOption.AllDirectories);Regards,Thanes
16 Dec 2015 by Bill Wagner
A C# 6 gotcha: Initialization vs. Expression Bodied Members
2 Apr 2018 by Member 13753157
My problem is that I have a code for the server and a code for the Clint and when I do not connect, What is the solution? This is the server code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using...
10 Oct 2016 by Rasmus Lindegaard
Hey AllAs the title says, all I'm really seeking out is a good guide on building MVC applications, preferably with the new Open Source tools from microsoft.I'm including vscode in this, because most guides assume Visual Studio Community (or above) and since I wish to do this the platform...
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...
27 May 2016 by Syed Janshair Khan
A first look at open-source .NET development with .NET Core and ASP.NET Core 1.0.
19 Oct 2015 by OriginalGriff
It doesn't quite work like that.We do not do your work for you.If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.But be aware: you get what you pay for. Pay peanuts, get monkeys.
21 Oct 2015 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Not a specific question. Next time please come with a specific programming issue.
16 Jun 2016 by rajaChowdare
why following is working?public abstract class AbsClass{public void ShowData(){Console.WriteLine("some text");}}public interface IInterface{public void ShowData();}class otherclassName :AbsClass,IInterface{Static Void Main(){}}above class i have not implemented...
16 Jun 2016 by OriginalGriff
Assuming you correct that so it compiles:public abstract class AbsClass { public void ShowData() { Console.WriteLine("some text"); } }public interface IInterface { void ShowData(); }class otherclassName : AbsClass, IInterface { static void Main() ...
16 Jun 2016 by Sergey Alexandrovich Kryukov
Please see my past answers referenced in this one: Why we need to create instance for interface not for implementation?.—SA
27 Mar 2019 by Florian Rappl, Manuel Römer
Supporting partial PUT (or PATCH) operations in ASP.NET Core with Newtonsoft.Json
20 May 2019 by GaneshBodke11
0 I have pulled one .net project from github. Opened it in Visual studio 19. There are multiple projects in Solution but only one project is giving the problem while building. Error is as follows : "Severity Code Description Project File Line Suppression State Error CS2012 Cannot open...
20 May 2019 by phil.o
There may be ntfs permission issues. You can issue these commands as an administrator: cd C:\Users\cloverspd1\Source takeown /R /F * icacls * /T /Q /C /RESET and see if that fixes the issue.
7 May 2015 by Mostafa Asaduzzaman
How to access configuration variables via dependency injection in MVC 6 - Visual Studio 2015 RC
28 Feb 2018 by Member 12210939
I have ComputerA on DomainA running as userA needing to copy a very large file to ComputerB on WorkgroupB which has the ip of 192.168.10.2 to a windows share that only userB has write access to and I get a System.Security.SecurityException "The name provided is not a properly formed account...
28 Feb 2018 by Richard MacCutchan
properly formed account name - Google Search[^]
21 Mar 2016 by Sajid_Qureshi
HiI am trying to access Photoshop document in C#.Can anybody help me how to start with?An actual few line code to open a PSD file will work for me. No pseudocode please.This would be much appreciated.What I have tried:I googled a lot but did not find any useful solution.
21 Mar 2016 by Richard MacCutchan
A few lines of code? You will need much more than that: see access Photoshop document in C# - Google Search[^].
29 Apr 2018 by Member 11381933
Hi I have a XAML requirement to add dashes when user is entering ssn in a text box. I tried below code, am able to add dashes, but unable to delete dashes from text box. Whenever i try to delete or use back space hyphens are not deleted What I have tried: XAML:
29 Apr 2018 by Wendelius
In order to correctly add or remove the hyphen you should handle for example UIElement.KeyDown Event (System.Windows)[^] . In the event handler, check if the user is adding text or removing it (backspace pressed). Also you need to take into consideration if delete key is pressed and/or if an...
13 Mar 2018 by David Cleeton
I have two repeaters one nested inside the other. The first repeater creates 12 rows, one for each month of the year. It works out the number of days for each month in turn and adds them to an array. The array is then used as the datasource for the second repeater. The second repeater checks...
22 Mar 2018 by zia khan
I have a code for drawing line on a canvas in wpf. The line is drawn using a mouse event. When the line is drawn it is also added to a list of Lines. I want to redraw those lines each time the canvas invalidate like we do in Paint event of winform Panel. private void...
22 Mar 2018 by Clifford Nelson
I am not sure I understand why you are making your life so difficult. If you bind to a viewmodel collection property, and the items in the collection support INotifyPropertyChanged, then any updates will be reflected on the canvas. Obviously there are certain performance issues always associated...
24 Nov 2015 by iamvinod34
Add reference from Class Library to Web Project doesn't work vs 2015??error message----->a reference to 'test123' could not added.
28 Dec 2018 by Member 14100488
I'm trying to make an C# Excel addin in order to automate the calculus of some cells value.What the addin should do is when a box is checked it should multiply the value of a cell with other cells and paste the result in different cells.The error that I get is "Cannot convert null to int because...
28 Dec 2018 by Maciej Los
The best way to resolve your issue is to use debugger[^]. As to the first error message: Quote: Cannot convert null to int because it is not a non nullable value type Yes, this might means that sheet.Cells[1, 12].Value2 holds nullable value. As to the second error message: you don't need to...
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:
13 Feb 2023 by Andre Oosthuizen
As per your link, a reference to ensuring the path is correct to your ADFS server - The path to the ADFS XML metadata is always your ADFS server FQDN, followed by a path to the FederationMetadata XML document To solve your problem, check...
6 May 2023 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
6 May 2023 by ahmed_sa
I working on MVC razor pages asp.net core 7 . I can't display success message after submit and insert data on same page . I get error System.NullReferenceException: 'Object reference not set to an instance of an object.' error happen on...
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....
25 Sep 2017 by SteveHolle
Do you have a new panel with the name Panel1? If you deleted the original and created a new Panel1 that might be the problem.
2 Jul 2016 by Alviss_H
I'm starting on a project to research about the algorithm of Youtube to check the license for videos.About the demo, I will use C# to create the tool. This is a small tool, with MSsql to store the DB(videos) and 'user' who can upload video. The tool will be checked it and reject it if this...
2 Jul 2016 by OriginalGriff
We can't help you with this: the code is proprietary to YouTube and so only they can legally give you any information.You could try contacting them - YouTube Contact Us[^] may help, they may be willign to give you info. Since it's a project, they might - but I wouldn't bank on it.
3 Jun 2020 by Member 13429250
I have these objects: txtb1 top: 150px left:450px txtb2 top: 270px left:450px txtb3 top: 390px left:450px I want to align these objects vertically and that it is inside the lPaneln Panel. Myglobal.txtb1.Attributes.Add("style", "position:...
27 Jan 2021 by Member 11760345
I have a user control MembersFoundControl.ascx that is loaded into the MembersControl.ascx when duplicate members are found. The MembersFoundControl control definition is:
27 Jan 2021 by Richard Deeming
You need to recreate the controls on every postback. The best place to do that would be the Init event of the placeholder you're adding them to. Dynamically Adding Wired Controls to Web Forms[^] Remember, your page and the entire control...
27 Jan 2021 by Member 11760345
I am not sure what you mean. The initialization of a control is OnInit. This would meant that this would fire everytime the MembersContol is refreshed. And the lifecycle of the MembersFoundControl is only for the duration of selecting one of...
24 Nov 2019 by Patrice T
Quote: A recursive generic method solution would be nice... I agree, it would be nice. Quote: An algorithm for calculating the minimum steps to balance list in C# So, This is homework, you show no attempt to solve the problem by yourself, you have no question, your main effort is pasting...
31 May 2018 by tsadak
Hello I have a question which is more algorithmic rather than programmatic. It follows: We have banknotes of 100, 50, 20, 10, 5 and 1 (whatever currency) in an ATM, with specific amounts of each denomination (you can check and get the amount of each denomination). A customer comes and wants to...
31 May 2018 by Patrice T
Quote: Solution is urgent and really really appreciate any help. Getting solution by hand should not be a problem. Think mechanical, write the procedure you are using to solve the problem, test it, refine. The procedure is your algorithm. We do not do your HomeWork. HomeWork is not set to test...
31 May 2018 by OriginalGriff
This homework problem isn't complex, if you think about it even for a few minutes. 1) Create a collection of the various banknotes that are available, order in descending value: 1000, 100, 50, 20, 10, 5, 1 2) Then loop while you have money to dispense, using each value in turn. 2.1) Integer...
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....
20 Aug 2020 by OriginalGriff
Read the error message: Session Provider, error: 19 - Physical connection is not usable) And if you don't understand it, a quick google takes you here: SQL Physical Connection is not usable[^]
12 Feb 2016 by SubhamoyBurman
This is how an idiot like me explains what is Abstract Factory pattern and how it could be used
23 Aug 2016 by Florian Rappl
This article describes the most important details of creating a useful bot using the Microsoft Bot Framework.
13 Dec 2015 by Member 12204785
hello , i want to create a WPF application in C# with with animation .. i have found Blend expression but i don't know how can i associate an expression from Blend expression 3 to Visual studio 2012 ... i don't find any solution .. any help ?? !! thank you
13 Dec 2015 by Dave Kreskowiak
You need to learn WPF and Blend. You're not going to get all the information you need from a couple of forum posts.Google for "Blend WPF tutorials".
13 Dec 2015 by Naz_Firdouse
Refer the samples athttp://www.c-sharpcorner.com/uploadfile/cd80b9/creating-an-animation-in-expression-blend-and-edit-in-visual-studio-2010/[^]http://www.kirupa.com/blend_wpf/[^]WPF Step by Step: Getting Started with WPF and Expression Blend[^]
5 Jan 2020 by OriginalGriff
Repost of How to develop application like udemy or online lectures[^] with even less information, no actual Question: Deleted.
11 Jun 2018 by Richard MacCutchan
See RegExr: Learn, Build, & Test RegEx[^].
11 Jun 2018 by Jochen Arndt
You will usually not find a solution that matches exactly your requirements. You have to know regular expressions (at least the basics) and do it yourself. When using the Regex.Replace Method (String, String) (System.Text.RegularExpressions)[^] you can use Substitutions in Regular Expressions |...
11 Jun 2018 by Maciej Los
You've got your answer here: C# string replace with regex[^]
1 Mar 2017 by Member 10377426
My Bad Company I Worked With, They Make ERP Sytems, They was use delphi and always looping in controls of the form and if control is text its fieldName with it`s Value taked in commandtext then applying INSERT, UPDATE, DELETE IN SQL For Fast Productivity Of Screen Because Clients Always asks for...
1 Mar 2017 by OriginalGriff
If that code is representative of your companies existing code, then you are lucky to still be in business. Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized...
4 Feb 2018 by David Cleeton
I have a modal dialog box which contains several textboxes and a couple of dropdownlists. The dialog is used to add a user to the system and works fine when adding just one user at a time. If I click the button to display the modal dialog a second time the dropdown boxes dont retain their...
3 Jan 2016 by JoaoSousa23
Using MVC, Entity Framework, ASP.NET Scaffolding you can create a web application that stores your information. This demo shows you how to create an ASP.NET 5 web application with MVC and Entity Framework 7.
24 Apr 2018 by Member 13795715
I am trying to send mail in outlook from office id but no mail is coming and error is operation time out. What I have tried: public void maildetails() { dt = dl.maildetails(bl); string header = "Innovation Gexin"; string body = "Our core team will be reviewing...
28 Sep 2017 by didourebai
The ASP.NET Core 1.x.x release does not include SignalR technology and development plans. Time has passed quickly, Microsoft has released a preview version of. NET Core 2.0 Preview 2.
10 Oct 2022 by syed shanu
Blazor Server APP in ASP.NET Core 6.0
20 Jun 2016 by Toan Manh Nguyen
In this article you will learn about ASP.NET Core RC2 using WEB API and AngularJS.
20 Jun 2016 by Toan Manh Nguyen
In this article, you will learn about ASP.NET Core RC2 using WEB API and AngularJS.
12 Nov 2018 by burakkucukekiciler
I want to make an unlimited category list, but can you help with HTML and the controller Model ; public class Category { public int Id { get; set; } public int SubCatid { get; set; } public string Name { get; set; } public List Category1 { get; set; } } I want to...
30 Apr 2019 by simple world
I fixed my problem when i created a new .cshtml file and followed this pages tutorial here With this now it logins my registered users.
25 Jan 2019 by Member 14129661
I have got the following set of code Task> getUsdExchangeRatesTask = Task.Factory.StartNew(() => _accountsService.GetExchangeRates("USA", "USD")); JobDetailsModel model =...
25 Jan 2019 by Richard MacCutchan
In your catch block you need to check which exception has been thrown. You can then decide whether you can just set the result to null, or need to take some further action.
28 May 2019 by user 3008
In moq setup I am trying to assign the value of one of the argument to a string variable. Although I used callback but still the variable seems to have null value. What I have tried: I tried this Mock partialMockLunaService = new Mock(MockBehavior.Strict); ...
28 May 2019 by Gerry Schmitz
Only you know which parameters will work. c# - Setting a passed parameter to a specific value in Moq - Stack Overflow[^]
25 Nov 2015 by Amir Dashti
Simply understand what happens when you use async/await keywords, what are the benefits and how to prevent deadlocks
3 Jun 2021 by Richard Deeming
If you're asking how to write your own mobile email client with the option to save the message, that is beyond the scope of a "quick answers" forum. If you're asking how to change an existing application to add this option, that's off-topic for...
26 Jul 2018 by itsathere
on mvc paging sorting locally works fine but on server getting error like belowAttempt by method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure)' to access type 'System.Linq.OrderedEnumerable`2'...
17 Feb 2017 by Mosti16
Use a custom Authorize Attribute which use a own PermissionProvider with custom Permission-Management.