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

C# 7.0 

9 Jun 2017 by Jeremy Madden
An attempt to introduce some Functional Programming concepts into an OOP domain
9 Apr 2019 by Fred Song (Melbourne)
Angular 7 with .NET Core 2.2 - Global Weather
7 Nov 2019 by koolprasad2003
This article will give you a brief idea about what's new in C# 7.1, 7.2, 7.3, 8.
14 May 2019 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
13 Jan 2020 by Marc Clifton
Implementations in C# and F#
3 Mar 2018 by Athari
CsConsoleFormat library for .NET - Formatting in Console using modern technologies
20 Apr 2018 by Eric Lynch
Part 3 in the LINQ series, this provides an introduction to IQueryable, IQueryProvider, and LINQ expression trees.
15 May 2018 by Eric Lynch
Extends .NET reflection to decode the byte array returned by System.Reflection.MethodBody.GetILByteArray(), discusses the techniques to achieve this, and provides a brief primer on .NET reflection.
11 Jun 2017 by Livio Francescucci
Use a JWTToken to access a .NET Core Web API leveraging IdentityServer4 / OAuth2.
24 Aug 2017 by Daniel Vaughan
Using steganography to conceal text within a document or watermark a code file, using a whitespace encoder. Hide text in plain sight!
29 Apr 2019 by Florian Rappl
Why not use serverless computing to perform maintenance tasks in Azure DevOps?
26 May 2017 by John Trinder
Comprehensive Multi-Slider(-Range) that can add, delete and move arrows (thumbs)
19 Aug 2017 by Afzaal Ahmad Zeeshan
.NET Core 2.0 brings a lot of improvements to the system, and it brings a lot of pain to the developers as well. I had a lot of problems upgrading .NET Core 1.x apps to .NET Core 2.0; I yet have to feel the promise it makes about performance and so, but let us see how to upgrade our existing applica
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.
20 May 2018 by Eric Lynch
In this article, we explore the implementation of a Visual Studio editor that allows editing of a fictitious "Colorful" language. The editor minimally implements both syntax classification / coloring and IntelliSense completion.
23 Apr 2017 by Kamran Bilgrami
C# 7.0 – Tuples Re-Engineered
28 Sep 2017 by Nikola M. Živković
Tuples in .NET World and C# 7 improvements
3 Mar 2019 by Clifford Nelson
This tip presents a behavior that will allow buttons to control the items in a WPF Selector (or ListBox) control.
15 Dec 2019 by Shao Voon Wong
Easier direct memory access in a safe way
1 Mar 2018 by Marc Clifton
One approach to creating the bidirectional relationship between context and data -- a declarative strongly typed relational contextual system using C#
6 Mar 2017 by Michael Doleman
A simple DAL with an integrated, lightweight model for database seeding from a JSON source, using the code-first method in Entity Framework.
13 Mar 2017 by defwebserver
You can create database driven .Net Core applications using JavaScriptServices, and PrimeNG.
9 Sep 2018 by Nick Polyak
Drag and drop using NP.Visuals package
8 Oct 2018 by outbred
Design, implementation, and usage of the oops framework
2 May 2018 by Clifford Nelson
The tip provides a behavior that will set a control to a default value when the Visibility changes
31 Oct 2018 by syed shanu
In this article, we will see how to work on Clustering model for predicting the Mobile used by model, Sex, before 2010 and After 2010 using the Clustering model with ML.NET.
29 Mar 2019 by Daniel Vaughan
Create a dynamic settings screen for your UWP app. Add a setting with a single line of code.
9 Feb 2016 by Bill Wagner
Continuing my discussion on proposed C# 7 features, let’s take a brief look at Slices.
16 May 2017 by Jochen Arndt
You have to know the type of data being passed. Without that information you can't do anything useful. If you know that the data represents some kind of file type you can try to detect the type. With Linux there is the file command that uses the magic(5): file command's magic pattern file -...
23 Aug 2017 by OriginalGriff
You added it to the class, but you don't appear to have a matching column in your database. As a result, SQL cannot handle any requests you make to that column. Add the column to the DB...
25 Sep 2017 by Vaidhya.P
The redirection will be based on the project structure you are using. NORMAL ASP.NET If you are not using any area's concepts then just Response.Redirect("Yourpage.aspx") MVC - WITH AREAS Concept MVC - WITH...
31 Jan 2018 by Pawel idzikowski
How to replace the web API request query string to provide case insensitive OData search
6 Mar 2018 by Maciej Los
Member 13711733[^] wrote: LongestRepetition(new [] {1, 2, 1, 2, 1, 2, 3, 2, 1, 2}) should return new [] {1, 2, 1, 2}. Why? It should logically return new [] {1, 2, 1, 2, 1, 2}, because it's a longest repetition. Check this generic linq solution: public static T[] GetLongestRepetition(T[]...
13 Mar 2018 by Richard Deeming
There's probably a more efficient solution, but this works with the input provided: static string ExplodeString(string value) { // Matches a repeated block which does not have a nested repeated block: Regex pattern = new Regex(@"(?\d+)\((?[^()]+)\)",...
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.
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...
30 Aug 2019 by OriginalGriff
Quotes won't help you at all: in C# the quote character delimits single character literal values: 'a', 'B', '1' Putting them round a line of code won't help. So try something like this: string path = @"D:\Test Data\MyFile.txt"; string allTheText = File.ReadAllText(path); The '@' in front of the...
30 Dec 2019 by OriginalGriff
Don't use ExecuteNonQuery - it doesn't return a result set at all, it returns a single integer. Instead, use an SqlDataAdapter and a DataSet to return the two result sets as separate tables. using (SqlConnection con = new SqlConnection(strConnect)) { ...
30 Dec 2022 by OriginalGriff
The last boot time is probably correct - it's just your idea of what you do with your computer that differs from Windows. With Win 10 / 11 (and maybe earlier, I'm not sure) "shutdown" and "restart" don't do what the name implies, not really -...
6 Sep 2023 by OriginalGriff
Dear Help Vampire: 30 seconds with Google will have told you what the error number means - it did me in less than ten. And then you would have realized that it's not a problem we could even begin to help you with, since it's related to...
8 May 2017 by CHill60
I would use ExecuteScalar to be more efficient... like this:private void btnNext_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex == -1) return; using (var conn = new SqlConnection(connstring)) { conn.Open(); var cmd = new SqlCommand { ...
9 May 2017 by OriginalGriff
Simple: Color c = Color.FromKnownColor(KnownColor.Desktop); And return it.
16 May 2017 by OriginalGriff
If you have tried methods from a different site, the most sensible thing to do would be to ask a question of the person who wrote the code, not a different site completely. The second most sensible thing would be to show the code you tried - as you tried it - by copy'n'pasting it into your...
19 May 2017 by Maciej Los
Depending on situation... I've tested below queries on that list: List lstA = new List { new A(){ ID = 1, lstB = new List() { new B(){ID = 1, Name="A", Path="C"}, new B(){ID = 2, Name="A", Path="D"}, new B(){ID = 3, Name="B", Path="E"}, new B(){ID...
31 May 2017 by AnvilRanger
You are loading over 2.2 millions rows of data from an XML file. I can just imagine the size of those XML files. Let alone loading them into memory and rendering the UI. Like F-ES said think about how a user will look at and use this data. The human eye and mind can only process so much data at...
6 Jun 2017 by Kornfeld Eliyahu Peter
At end of the day ASP.NET MVC will not work properly without those folders (Model, View, Controller)... So even you pick the empty template you will need them, and that means, that you have two choices - add those folders to the empty project, or clean the full project... What to pick? It depend...
20 Jun 2017 by Patrice T
Try private void save_Click(object sender, EventArgs e) { Properties.Settings.Default.Source = textBox1.Text; Properties.Settings.Default.Save(); Application.Exit(); }
27 Aug 2017 by OriginalGriff
The way I'd do it is to use Distinct with a comparer: public class MyClass { public string Name { get; set; } public string Other { get; set; } public MyClass(string a, string b) { Name = a; Other = b; ...
24 Sep 2017 by Richard MacCutchan
Possible? Maybe: see ListBox Class (System.Windows.Controls)[^].
25 Sep 2017 by F-ES Sitecore
List Leave the "Controller" suffix off the controller name, so if the class is called HomeController you use just "Home" as the controller name.
29 Sep 2017 by OriginalGriff
That's not going to be easy - a double in C# only has 15~16 digit precision: double (C# Reference) | Microsoft Docs[^] so the normal "multiply and remove teh integer part is not goign to work. In fact, it quite likely that the "15th digit after the float point" is not stored at all - bear in...
25 Oct 2017 by Sheila Pontes
Hi, To display the two data from the datatable columns in your dropdownlist, I suggest that you format the data before bind it. Use linq for this. This is the easiest way. Here is an example of this suggestion. HTML
3 Nov 2017 by Karthik_Mahalingam
try protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") // name of the command { var index = Convert.ToInt32(e.CommandArgument); var row = GridView1.Rows[index]; ...
18 Dec 2017 by OriginalGriff
We can't help you - we aren't a tutorial service and we can't "explain C#7" in a small text box: there are whole books devoted to it, and big ones. And that is the resolution to your problem: get a book (or better go on a course) instead of watching YouTube videos, which are mostly made by...
14 Jan 2018 by David_Wimbley
So first thing, in your RBOleDb class, your DbType, DbDataSource, DbPath, and DbProvider all lack a setter in the property so i'm not sure how your code even compiles so you'll need to change those from public string DbType { get; } to public string DbType { get; set; }. Next thing I see, you...
18 Mar 2018 by OriginalGriff
First off, don't use Convert methods: users mistype the input all the time, and the Convert methods will make you app crash if they do that. Use the double.TryParse methods instead. In fact, that's a good intro to using a method. At the moment, you do the same thing a number of times: ...
2 Jul 2018 by OriginalGriff
Don't translate them: they are very different languages and you will not end up with good quality code in C#. What you are trying to do is translate Shakespeare's plays to Korean using Google translate to look up each word: To be or not to be, that is the question 에 있다 또는 아니 에 있다 그 ~이다. 그만큼 문제...
23 Aug 2018 by Dave Kreskowiak
You don't. In simple terms, variable names only exist until compile-time. If you want a "variable" to hold a value, you would normally keep such things in a Dictionary collection. It's not a true variable in the sense you're talking about, but the name entered becomes a "key" in the collection,...
7 Oct 2018 by David A. Gray
This article demonstrates a class library that supports command line parameters with default values stored in application settings.
21 Sep 2018 by OriginalGriff
f is static: there is one of it for the whole application. Because both B and C are derived from A, they share the same static variable: the last value to you set it to will be the global value it has, regardless of whether you set it via an instance of B or C So which ever instance you create...
19 Oct 2018 by David O'Neil
int main() { play(paper); play(something); play(scissors); play(paper); return 0; } Hope this helps get you started Or maybe it will make you mad enough to try on your own, and show this a***hole (being me) what a jerk I am by succeeding. Or at least...
2 Nov 2018 by Richard Deeming
Use HttpFileCollectionBase.GetMultiple[^] to retrieve the list of posted files for each input: IList additionalDocs = Request.Files.GetMultiple("AdditionalDocs"); IList budgetDocs = Request.Files.GetMultiple("BudgetDocs"); IList...
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...
23 Dec 2018 by Richard MacCutchan
The logic is fairly straightforward: byteArray = // input data numberOfBytes = // length of input data blockSize = 8 offset = 0 WHILE numberOfBytes > 0 DO copybytes(byteArray[offset], destinationAddress, blocksize) // copy a block offset += blockSize ...
30 Dec 2018 by RickZeeland
In C# you can use System.Net.NetworkInformation, see example here: Using ping in c# - Stack Overflow[^]
21 Feb 2019 by Dave Kreskowiak
Your problem description isn't clear at all. In Task Scheduler, you can schedule as many tasks as you want and they can be executed at the same time. You just set the time in the task when you want it to execute. There's nothing that says you can only have one task running at a time. In your...
22 Feb 2019 by Afzaal Ahmad Zeeshan
Your question itself has the answer, your task has not yet been evaluated—Result = "{Not yet computed}. You need to give it more time, and check the result later. This time won't be known to you, since it is undefined amount of time. That is because in the synchronous code you need to wait for...
4 Mar 2019 by OriginalGriff
No, because we have a number of members who would think it funny to post extremely inappropriate images. And that means every image post would have to be individually moderated before they were posted and we really don't have enough volunteers to do that with nearly fourteen million potential...
27 Mar 2019 by Florian Rappl, Manuel Römer
Supporting partial PUT (or PATCH) operations in ASP.NET Core with Newtonsoft.Json
24 Aug 2019 by Charles Jenkins
In full-row selection mode, the WPF DataGrid wants to scroll horizontally when a user clicks on a cell which extends offscreen. This sample project shows one way to prevent it.
27 Aug 2019 by Richard Deeming
The problem seems to be that you don't have a wrapping element, so the array attributes are ignored. If you had: then your code would work. Without the wrapping element, it looks like...
1 Oct 2019 by Richard Deeming
Simple - just remove the async keyword: protected virtual Task MyFunction() { return Task.FromResult(string.Empty); } If your task completes synchronously most of the time, you might want to consider using ValueTask instead. Understanding the Whys, Whats, and Whens of ValueTask |...
28 Nov 2019 by Maciej Los
At the first look, i see 3 errors: 1. //missing [s] in url addresss string urlAddressofW = "https://google.com/search?q=" + ADDING; 2. //Google replaces spaces [" "] with [+] ADDING = PureTexttitle.Replace(" ", "+"); 3. //missing [W] in receiveStream if (responseW.StatusCode ==...
2 Dec 2019 by Ashutosh Gpt
it is also depends on how you have set the output directory of each project. if A is depends on B and C, modifying just member/ properties etc does not required to rebuild the project A. you can just build B and C. if C & B has interfaces which was used in project A that also just required to...
16 Dec 2019 by OriginalGriff
That's trivial code: Open a file Get a file name Remove the extension. Create and open the new file Open the ZIP archive you started with Extract the file. If you can't work that out, you are punching way above your weight, and need to go back to your tutorials and learn C# properly.
17 Feb 2020 by OriginalGriff
You can't "solve" an in put string format problem: it says what it means: the user typed a value that cannot be interpreted as a valid double You can prevent you app from crashing though: double R; while (true) { Console.Write("Please...
8 Apr 2020 by OriginalGriff
Try: private const string NotAllowed = @">
18 Jul 2020 by OriginalGriff
Because the language designers decided not to allow it. There is a deeper reason for this in that it adds a lot of complexity with not a lot of "real" benefit, and the reason for that is called the Diamond Problem: Multiple inheritance -...
28 Jul 2020 by Mirambek Nagashbekov
Demonstration of filter pattern along with pipeline on data driven application
18 Aug 2020 by Sandeep Mewara
AFAIK / understand, Quote from Heading 1[^] : Decoupling presentation logic from application logic is the basic motive behind the Document-View architecture used by MFC applications. For example, assume we use the App Wizard to create an...
7 May 2021 by Richard MacCutchan
Your code can be simplified to the following: using System.IO; using System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { Dictionary players = new...
23 Dec 2021 by OriginalGriff
Quote: Please I want to Learn How to Create Function To RemoveAt element from Array Without Using built-in Function The array in C# is not a "resizable" object - to genuinely add or remove an item you need to create a new array and fill it with...
17 Jan 2022 by Richard Deeming
If you want to set the header via code, the simplest option is to add another parameter, pass the required title in that parameter, and set the text box's text to that parameter. Otherwise, you could use an expression for the text box parameter,...
19 Nov 2022 by Graeme_Grant
Why not serialize to JSON and write as text, then you can read the text and deserialize it to an object. UPDATE Simple example... sample class to be stored and retrieved: public class Theme { public string ForeColor { get; set; } ...
17 Dec 2022 by Graeme_Grant
LiveCharts - LiveCharts2[^] is very simple to use. The documentation is very good with code samples given. From their documentation, ref: samples.bars.withBackground - LiveCharts2[^] 1. ViewModel using CommunityToolkit.Mvvm.ComponentModel;...
23 Aug 2023 by OriginalGriff
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 queries instead. When you concatenate strings, you cause...
27 Nov 2023 by Graeme_Grant
Looks like a copy & paste error. Change: "ConnectionStrings": { "MovieContext": "Server=(localdb)\\mssqllocaldb;Database=Movies;Trusted_Connection=True;MultipleActiveResultSets=true\"" } to: "ConnectionStrings": { "MovieContext":...
29 Nov 2023 by Richard Deeming
Quote: The sceffold command now looks like this. Scaffold-DbContext -Provider Microsoft.EntityFrameworkCore.SqlServer -Force -OutputDir Model -Connection "Data Source=MSIBeast\SQLEXPRESS";Initial...
18 Dec 2023 by M Imran Ansari
As the error message, the issue is in Delete method. The Delete method attempts to remove an entity from the context using LapShopContext.Set().Remove(entity). However, the error you're encountering is a NullReferenceException, which suggests...
9 Feb 2024 by Graeme_Grant
Here is your problem: T.TryConvertFromChecked(toUnit.CompoundFactor, out var toCompoundFactor) This calls the TryConvertFromChecked in the readonly struct Double. Here is the method: static bool...
5 May 2017 by CHill60
Use a parameterized query such as this (untested): var cmd = new SqlCommand(); cmd.CommandText = "UPDATE input_tb SET place_no=@place,price=@price,curr=@curr,E_date=@E_date,m_type=@m_type,matter_q=@matter_q,unit1=@unit1',Worker=@Worker,f_note=@f_note FROM input_tb INNER JOIN Place_tb ON...
8 May 2017 by Patrice T
Use a debugger and look at cmd to see what is your real query. Never build an SQL query by concatenating with user inputs, it is named "SQL injection", it is dangerous for your database and error prone. A single quote in a name and your program crash. If a user input like "Brian O'Conner" can...
14 May 2017 by pradiprenushe
You are returning single Alumno entity to view Alumno p1 = new Alumno(); return View(p1); And using as list in view. First clear your requirement. Are you really want to show list on view if not then dont use list in view. Two option 1. Either remove list from view 2. Pass list of alumno...
15 May 2017 by OriginalGriff
Start by finding an appropriate fingerprint scanning device, and talk the the manufacturers, or browse their website - we have no idea what device you will be using, or what you are supposed to be doing with it. Research, planning, specification, and design are all parts of you project: so you...
15 May 2017 by OriginalGriff
Am tried this one ^[\w]{1}$ But its allowed only one character. more than one character failed. That's because that is exactly what you told it to do: {1} means "exactly one of" - and is redundant, as is most of that Regex, which reduces to: ^\w$ If you want one or more, then try ^\w+$ If...
16 May 2017 by ZurdoDev
No, it is not possible because servers do not expose their file structure. There used to be a setting (and may still be) in IIS to allow listing of directory contents but it is not on by default for security settings.
16 May 2017 by Richard Deeming
You're trying to answer the wrong question. :) Don't try to find a way to use Javascript to close the browser window. Even if you find a hack to let you do that, it will be a bug in the browser, and will most likely be patched, breaking your script. Instead, use a different tool to make the...
16 May 2017 by Kornfeld Eliyahu Peter
These parts of redist are not documented as far as I know... However here how you can parse it... First notice that the data is separated by classic C carriage-return+newline (\r\n)... So you should interpret it line by line... Lines beginning with * (asterisk) are counters... So the first line...
17 May 2017 by David_Wimbley
You are "encrypting" (really hashing) your passwords using MD5. Because it is being hashed you can't/don't decrypt it, you merely compare your hashes to decide if the user is authenticated or not. If you are wanting to decrypt the password as a easy way to remedy "i forgot my password" you are...
17 May 2017 by Patrice T
Quote: i have a Encrypt Password method need decrypt password method in c# There is no decryption possibility because MD5 is not encryption, it is hashing. Hashing is a one way process and can't be reversed. MD5 - Wikipedia[^] Hash function - Wikipedia[^]