Click here to Skip to main content
15,891,375 members
Everything / Programming Languages / C# 7.0

C# 7.0

C#7.0

Great Reads

by Jeremy Madden
An attempt to introduce some Functional Programming concepts into an OOP domain
by Fred Song (Melbourne)
Angular 7 with .NET Core 2.2 - Global Weather
by koolprasad2003
This article will give you a brief idea about what's new in C# 7.1, 7.2, 7.3, 8.
by honey the codewitch
An LL(1) pull parser and generator that thinks it's an LL(k) parser - with a rich, simple and beautiful EBNF syntax

Latest Articles

by Dave Elliott
A series of 6 articles to provide you with a boilerplate guide to create Source Generators.
by Illya Reznykov
How to mock & test methods with out parameters
by Vikas Sharma
Build a robust authentication and authorization system using IdentityServer and ASP.NET Core 3.1
by Mirambek Nagashbekov
Demonstration of filter pattern along with pipeline on data driven application

All Articles

Sort by Title

C# 7.0 

16 Apr 2019 by OriginalGriff
Deleting doesn't seem to be working: so I'll post this here to remove it from the "unanswered" queue and delete it later when the DB is feeling less "fragile"... This is the same question as you posted yesterday: Power shell commands returning the improper user name format[^] Please do not...
10 Dec 2017 by Member 13507572
I am trying to pass valued from my database to a shared view but I keep getting this error (Please note I am very new to MVC, so I dont understand the error I get) - The model item passed into the dictionary is of type...
20 Sep 2019 by Member 13975267
Hi All, I am new to .NET Core. I am working on a new project where we will have REST APIs that should be used by thousands of users at the same time. The REST APIs will use Entity Framework to update and return data from a SQL server database. We use Unit tests and logging(log4net) extensively....
6 Sep 2018 by Richard MacCutchan
1. Impossible to guess as it depends on so many variables. 2. dot net core support unit testing and logging - Google Search[^]. 3. You need to be more specific.
6 Sep 2018 by Vincent Maverick Durano
Quote: I found that dot net core does not have all the dot net framework APIs. True but the latest version of .NET Core should include the core features and APIs you need to get you started and build the app. Keep in mind that the .NET Core framework is designed to be cross-platform, so you...
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.
29 Aug 2017 by Ammar Shaukat
I’m currently working on a UWP app to work with scanners. This application is a POS app and reads barcodes. Windows 10 Provides its built in barcode scanner class. That is used for UWP apps but it is limited in functionalities. you can check it here. Window 10 barcode Scanner for UWP
29 Aug 2017 by Dave Kreskowiak
Some COM components work in UWP apps, most don't. Why? UWP applications run in a "sandbox" where the application needs permissions to do just about anything. They are restricted to using a limited subset of the Win32 and COM API's. Most existing COM components, unless they are explicitly...
26 Jun 2018 by Member 13725613
Hi all, since a while im using the TreeViews with Checkboxes in WPF. I found a good solution here on this page: tps://www.codeproject.com/Articles/28306/Working-with-Checkboxes-in-the-WPF-TreeView However, I have problems to bring in a TemplateSelector correct into this code. I just want...
25 Oct 2018 by Ben Hall (failingfast.io)
Reviewing what we need to know pre- and post- C# 7 features about the type system and in particular, reference types and reference-like behaviour, while correcting common misconceptions along the way.
18 Jun 2017 by Nikola M. Živković
Moving from switch-case to object oriented code, and pattern matching
27 Mar 2019 by Florian Rappl, Manuel Römer
Supporting partial PUT (or PATCH) operations in ASP.NET Core with Newtonsoft.Json
15 Jun 2023 by Tim the Gamer
Suppose I have a list of student objects where a single student has the properties Name, Age and Company properties. I would like to implement extra Comparer interfaces that will allow me to sort a list of students using the Age and company...
15 Jun 2023 by Richard Deeming
Rather than having the class implement the comparison, use external classes implementing IComparer. public abstract class PersonComparer : IComparer { public int Compare(IPerson left, IPerson right) { if (left...
29 Sep 2018 by 855
I have an image like 1.png, in the image there are two fields on it. like below: Name: Date: i have an app to receive the name and date from user, then put the values on the image Name: John Date: 2018-10-01 and save it as john.png. how to implement this using C#? Thank you! What I have...
29 Sep 2018 by OriginalGriff
Assuming your image has the name and date areas in the same place each time, then it's not too difficult: using (Image i = Image.FromFile(inputPath)) { using (Graphics g = Graphics.FromImage(i)) { ...
20 Oct 2020 by patrickb123
Hi I am currently using Basic Sharp link: https://github.com/Timu5/BasicSharp This is a basic language interpreter. We need to use merge fields in this code to replace mergefields with values. For example: IF {Clients.Name} = "Patrick" THEN #Do...
20 Oct 2020 by Gerry Schmitz
Why don't you use a "proper" (replacement) token like $CLIENT or something (instead of a variable name). e.g. ...Replace( "$CLIENT", xxx ). (And read the whole text file into a string; instead of line by line).
18 May 2020 by Member 12885549
I am implementing queues using https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-3.1&tabs=visual-studio example. this is how my code looks: in startup.cs I am adding my hosted service and background...
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.
24 Apr 2018 by didourebai
Mobile alerts in Xamarim.forms
24 Feb 2019 by ahmed_sa
Problem ambiguous error happen when build project on visual studio 2015 ? error : Combined length of user strings used by the program exceeds allowed limit.. How to solve this error please ? my project big and have more files and cannot know on which place this problem come problem...
24 Feb 2019 by CHill60
Well I wouldn't call that "ambiguous"! You have exceeded the amount of string literals that the compiler can handle and you need to reduce that. Here are some ideas to help you do that: If you are using the same text repeatedly (e.g. In error messages) then consider using Consts to minimize...
23 Oct 2017 by Member 12380485
Hello, I want to know how to make a an android tcp client that is going to send the data like an message to a server which is built in visual studio c# using sockets. What I have tried: I am trying using sockets in android but unable to do it. Please help ..
23 Oct 2017 by Richard MacCutchan
Socket | Android Developers[^]
23 Oct 2017 by Afzaal Ahmad Zeeshan
This is a question that we get most often, in this category. For example, have a look at the answer that I provided a few weeks ago: Android TCP client and C# visual studio server how to do it.[^]. The thing is you need to understand that Android as well as .NET framework, both support TCP...
10 Mar 2019 by Fred Song (Melbourne)
Angular 7 with .NET Core 2.2 - Global Weather (Part 2)
9 Apr 2019 by Fred Song (Melbourne)
Angular 7 with .NET Core 2.2 - Global Weather
17 Dec 2018 by OriginalGriff
And how does this differ in any material way from your last question: How to crop an image in an appropriate way, C#?[^] The solution you have been given does not change just because you don't like the answer!
13 Nov 2017 by thready
Hi folks, I have an activeMQ broker url that starts with activemq:tcp://host:port I also have referenced Apache.NMS, Apache.NMS.ActiveMQ and Ionic.Zip in my project. When the following line is run, I get the exception: "Apache.NMS.NMSConnectionException: 'No IConnectionFactory implementation...
16 Jul 2019 by Nice Kloe
Afternoon, I'm doing an app in which one of the modules includes sending email from the ASP.Net MVC app. Here's what I already have : //This is email creation var body = "Email From: {0} ({1})Message: Morning. This is a test trying sending emails from ASP.Net MVC....
16 Jul 2019 by MadMyche
The most common issues I have seen with gmail is 1. Google does not recognize the connection being used for the particular email account being used. The best thing to do is to go to their Login Activity page and tell them basically that "yes, that was me" Sign in - Google Accounts[^] 2....
21 Aug 2018 by Leonardo Guimarães
I am trying to make a program that allows the user to export data to txt, however I want first to ask user what is the path to create the txt. However I'm not getting right the replace function, I doing adding a variable. Sorry if it's a sily question. What I have tried: string path =...
20 Aug 2018 by Richard MacCutchan
I do not think that the Replace method uses format strings, as they have no meaning in this context. See String.Replace Method (System) | Microsoft Docs[^].
20 Aug 2018 by Dave Kreskowiak
Why are you even using a Replace? You should be getting the folder path from the user, making sure it exists or you create the path, then you append the filename to the path using Path.Combine(). string folderPath = Console.ReadLine(); if (!Directory.Exists(path) { // The...
21 Aug 2018 by Leonardo Guimarães
I mean what try will try to do, create a file or a directory? and also the txt will be created where if in the example above it's not being asked to user the path?
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.
11 Jun 2017 by Livio Francescucci
Use a JWTToken to access a .NET Core Web API leveraging IdentityServer4 / OAuth2.
5 Oct 2020 by Vikas Sharma
Build a robust authentication and authorization system using IdentityServer and ASP.NET Core 3.1
18 May 2017 by Chriz12
Hello, I have 2 applications running on IIS 8.5. Both of the applications need authentication. For the Authentication I used the Identity Data Model. When I run the applications from the debugger I have no problem login more than one user at the time. When I take them to the IIS the...
18 Oct 2017 by Chriz12
Here's the solution if someone else is facing similar issues. Katana Project - Documentation[^]
27 Oct 2017 by tieudoan208
Hi all I create other project classLibrary with Name CORE Contain javascript file and view (cshtml). i create an project asp MVC has referent CORE.dll, i wanna used javascript and view in core.dll for this project. but i dont how to call it ? please help me What I have tried: In project...
27 Oct 2017 by Richard MacCutchan
classLibrary with Name CORE Contain javascript - Google Search[^].
29 May 2017 by Member 13230054
which design pattern do you implement in order to improve unit testing in your code by loosely coupling object dependencies through object constructor arguments? 1-adapter 2-Dependency Injection 3-Abstract Factory 4-Observer 5-Singleton What I have tried: which design pattern do you...
29 May 2017 by Member 13230250
Answer:Dependency Injection Dependency Injection (DI), also more cryptically known as "Inversion of Control" (IoC), can be used as a technique for encouraging this loose coupling. There are two primary approaches to implementing DI: constructor injection and setter injection. Obviously, at...
19 Apr 2020 by Roland Roos ICT Architectures
Using patterns like aspect-oriented programming in modern OO-languages in micro-services context
1 Apr 2018 by Daniel Vaughan
Learn how to leverage the asynchronous ICommand implementation in Codon FX to support commands that kick-off long-running operations.
28 Oct 2017 by Member 11685924
when press print button in crystal viwer to print any report i made in my own project it gives me the error" Attempted to read or write protected memory. This is often an indication that other memory corrupt" What I have tried: i tried to convert properties from any cpu to 32x it works only i...
1 Jun 2020 by sam_roy
I have 4 classes namely ClassA, ClassADto, ClassAA(inner class to ClassA) and the final Result class. public class InnerA { public int HouseNumber{get;set;} public string StreetName{get;set;} public string State{get;set;} } public class A {...
1 Jun 2020 by Maciej Los
This is not an answer, but i have too many doubts to post it as a comment. 1. I don't understand the reason of creating two classes containing almost the same data, where an ADto should be a base class for A. Take a deeper look at them: ...
9 Dec 2017 by Sacha Barber
Small demo of using Azure Functions and Azure EventGrid together
11 Jan 2018 by Allister Beharry
.NET SIMD programs using the Vector types show performance comparable to Intel ISPC and open source C++ SIMD libraries while satisfying the same goal of SIMD developer productivity in a high-level language.
8 May 2018 by Mohit Tomar
Hi, I have been learning to code in c# and had just started. For practicing what I have learned I searched online for some good resources where I can find some basic questions based on c#. So far what I come across is either too hard or the questions contain advanced topics that I have not...
8 May 2018 by Richard MacCutchan
Try this excellent free guide: .NET Book Zero by Charles Petzold[^].
8 May 2018 by Patrice T
Quote: Hi, I have been learning to code in c# and had just started. Learning to code is far more that learning a programming language; You have to know that you can do pretty much anything in any language, simply some languages are harder for beginners because there is more pitfalls to handle....
19 Sep 2017 by Member 13373000
I am using a COM Interface where I am receiving byte data representing a DIP (Device Independent Bitmap). I want take this byte[] and copy its data into a BITMAPINFOHEADER variable. I have a long piece of code and this is only part of it, however it is written in VBA and it works: Private...
22 Aug 2017 by Jochen Arndt
You are copying to bimPtr (allocated memory) but print out bim.biSize (bim is allocated but never changed). Instead of trying to convert VBA code that calls an API function to copy memory (which calls the standard C library function memcpy in the background), you should understand what the code...
18 Jan 2024 by Dave Elliott
A series of 6 articles to provide you with a boilerplate guide to create Source Generators.
15 May 2017 by Samira Radwan
Hi All, I need to browse a directory in a webform using ASP.NET. I managed to get all the sub-directories of the selected folder/directory, but the problem is I don't know how many levels of sub-directories I have for each directory. For example If I browse a folder/directory called AA that has...
15 May 2017 by Samira Radwan
I managed to do it using TreeView. I have created two functions, one to populate TreeView if there's sub-directories and the other to populate TreeView if there's no folders. First one: private void PopulateTreeView_WithDirectories(DirectoryInfo dirInfo,TreeView treeView, TreeNode treeNode) ...
14 Jun 2018 by paolo guccini
How to use the Microsoft Interop/Automation to implement parallel research of a Microsoft Office file password.
13 Oct 2016 by didourebai
This post is about developing ASP.NET Core application using EF Core, we will demonstrate how we can connect in different ways to SQL Server Database and Postgresql Database.
30 Jan 2019 by Member 13325846
Hi, I am going to learn about how to map a BUS System (WAGO 750-342) and how to read sensors data from them and to show pulse of each sensor in a textbox. i have knowledge about TCP/IP but i have no knowledge about how can i map which module is incremental, Analog or digital and read their...
30 Jan 2019 by RickZeeland
See this ModBus library: GitHub - NModbus4/NModbus4: NModbus4 is a C# implementation of the Modbus protocol.[^] And: EasymodbusTCP Modbus Library for .NET/Java and Python – Communication library and professional tools for industrial communication[^] Also see: Wago I/O 750-370 communication[^]
31 May 2021 by durim kolukaj
private void button_Login_Click(object sender, EventArgs e) { string query = "Select * from Members Where Email= '" + UserEmail + "'AND Password= '" + UserPassword + "'"; dataBase.readDatathroughAdapter(query,...
31 May 2021 by OriginalGriff
You have bigger problems than the one you've spotted... Firstly, 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...
8 Apr 2020 by LSB71
Hello, I just created this condition to block special characters. it works, but can we make it simpler? Who can bring me a better solution? What I have tried: private void textbox1_KeyPress(object sender, KeyPressEventArgs e) ...
8 Apr 2020 by OriginalGriff
Try: private const string NotAllowed = @">
8 Apr 2020 by Maciej Los
Another way is to use ErrorProvider Component Overview - Windows Forms | Microsoft Docs[^]. You can validate value entered in a textbox and display error icon near the textbox. Display Error Icons for Form Validation with ErrorProvider...
28 Sep 2017 by Member 13435649
I would like to request some help on creating a c# based sign in and out form that uses a local sql datbase to store people signing in and then out again There are no errors however the form will not accept any data and the sign out form drop box will not populate with names of people from...
28 Sep 2017 by Patrice T
string query = "INSERT INTO Person (Name,Organisation,TimeIn) VALUES('" + name + "','" + organisation + "','" + strDateTimeIn + "')"; Not a solution to your question, but another problem you have. Never build an SQL query by concatenating strings. Sooner or later, you will do it with user...
14 Nov 2017 by gani7787
Hi, I am using datagridview. i just want to update the combobox cell value. i cell value should update based on my condition. But, the problem is, combobox value displaying which is last executed value only always. the remining condition is updating the cell. what is the problem in my code. ...
14 Nov 2017 by gani7787
Thanks. i tried one more ideas. I have added different list item to map the combo box cell. it's also working. Example List Emplist1 = new List(); List Emplist2 = new List(); foreach (DataRow row in dt.Rows) { Grid1.Rows.Add(); Grid1[0,...
22 Nov 2017 by gani7787
Hi, I am doing some calculation based on my excel input. This Excel user can select from the particular path and then select the file. But, now client wants, they don't want to select excel file from the path. Instead of that, they will mention the file path in the INI file. While loading...
22 Nov 2017 by Richard MacCutchan
C# read ini file- Google Search[^]
13 Oct 2017 by gani7787
Hi, I have one datatable. it contains 100 columns. the problem is i don't want to check all the columns in the table. I just want to check column from 25 to 50 in sequence. finally i have the score and that i want to compare in that column (25 to 50) values. if any score value is matching...
13 Oct 2017 by Karthik_Mahalingam
try foreach (DataRow row in dt.Rows) { for (int i = 25; i
13 Oct 2017 by OriginalGriff
If you want to check a specific range, don't use a foreach, use a for instead: foreach (DataRow row in result) { for (int colIndex = 25; colIndex
4 Apr 2019 by MichaelecG
I have Explorer.exe started using process.Start() to try to read a network location and, if ok, it just shuts down explorer.exe and program continues. If the NW location is unable to be opened by explorer.exe I wish to read the error message. I am an elderly complete amateur and any help would...
4 Apr 2019 by #realJSOP
You can use HTTPWebRequest and HTTPWebResponse to do this without running IE. The web response will contain the error. How to: Request data by using the WebRequest class | Microsoft Docs[^]
4 Apr 2019 by MichaelecG
Sorry about the unclear bit - the 'network location' is a drive on my home network. The drive is used to store files so that my wife and I can both use them. I have a prog that checks the drive and then copies whatever program is to run to the appropriate PC and then runs that prog locally - eg...
19 Jun 2018 by Member 13877172
Hey guys, I want to identify the potential of developing dashboarding and data analysis functionality with C#. What do I want to do?: I want to know how it is possible with C# to load a data model (SQL, OLAP, ...) into a web application and do some analysis on it (diagram, filtering, ...) with...
19 Jun 2018 by Maciej Los
First of all, there's lot of ASP.NET controls[^] you can use for free! You don't need devexpress or telerik. So, depending on requirements, you can build any GUI. See: Getting Started with Chart Controls[^] I'm sure that visual representation of data is very important, but much more important...
20 Dec 2018 by uncommon_name
Hello =) regrettably I have no idea about C#. It's my first little C# project. I just want to move all Excel files from the folder A to B. That's it. Unfortunately, the files are not moved. =( I hope you can help me. What I have tried: using System; using System.Collections.Generic;...
20 Dec 2018 by Richard Deeming
File.Move will only move a single file; it doesn't know how to process wildcards. You need to list the files you want to move, and move them individually: string sourcePath = @"C:\Users\Chris\Desktop\"; string destinationPath = @"C:\Users\Chris\Documents\Excel\"; foreach (string sourceFile in...
11 Oct 2017 by gani7787
Hi, I am getting Error while i am forming the statement. Mycolname = "WIN TAG"; sqlcmd = ( Stundetno = '101') and ( WIN TAG = 'A1' ) DataRow[] result = dt.Select(sqlcmd); // Error : Syntax error: Missing operand after 'TAG' operator. what is the Error...? What I have tried: qlcmd = ...
11 Oct 2017 by OriginalGriff
Spaces aren't allowed in SQL names unless they are enclosed. Try this: sqlcmd = "( Stundetno = '101') and ( [WIN TAG] = 'A1' )";
9 Feb 2016 by Bill Wagner
Continuing my discussion on proposed C# 7 features, let’s take a brief look at Slices.
15 Dec 2019 by Shao Voon Wong
Easier direct memory access in a safe way
23 Apr 2017 by Kamran Bilgrami
C# 7.0 – Tuples Re-Engineered
1 Nov 2016 by Rion Williams
C#7.0: Tuples to the extreme!
13 Sep 2017 by Member 13373000
I am working with COM Interface of a software, OMICRON MPD 600 to be particular. I would like to take a screenshot using the provided methods however it returns the image as DIB populated inside byte array. How can use this byte array to save this screenshot as an image. I would prefer DIB to...
13 Sep 2017 by Graeme_Grant
There is an article right here on Code Project that will answer this for you: DIB to System.Bitmap[^]
16 Jul 2018 by AminMhmdi
i have some mp3 collection and i want to able play it on CD/DVD i write audio player using c# but i dont know how to protect my audio file is there any way to encrypt audio files ?? what is best way to do it to protect this audio file from illegal use? What I have tried: i play sound using...
16 Jul 2018 by Dave Kreskowiak
You don't have a simple method to do that. In order to use the built in player, the data has to be unencrypted. Now, that's not to say it's impossible. You just have to write an audio filter driver[^] (in C) that decrypts the stream on-the-fly. The filter driver would sit in the filter graph...
28 Jan 2018 by ravijv
I Have 3 URLs Ex : 1.YouTube.com 2.Google.com 3.CodeProject.com From here i am downloading data from each URL. If I downLoad 1GB of data , other 2 URL automatically stops downloading. for this just tel me what i have to do to communicate between each URL. Sample code highly appreciated.. ...