Everything C#
Everything C#
  • 33
  • 250 938
Property name from lambda expression in C#
A common pattern in C# is to pass a property name by using a lambda expression as the parameter. This video shows how to extract that property name from the passed in lambda expression.
The crucial code you need is the following:-
var expression = (MemberExpression)action.Body;
string propertyName = expression.Member.Name;
Effective C# answers common questions about the C# language and the dotnet ecosystem. If you have a programming question about C# or .net then add it as a comment below.
GitHub: github.com/ComponentFactory/CSharpAnswers
Переглядів: 885

Відео

Unleash the Full Potential of C# with These List Patterns
Переглядів 758Рік тому
C# has introduced list patterns that allow for simpler, more concise and readable code. Combining existing patterns such as discard, property, logical and so forth makes pattern matching more powerful than ever.
Visual Studio Code and C#: Getting started using these 6 extensions
Переглядів 26 тис.Рік тому
To get the perfect setup for C# and Visual Studio Code you need the 6 extensions outlined in this video. Plus, an extra setting that few know but everyone should be using. 1: C# 2: C# Extensions 3: .NET Code Test Explorer 4: Rosylnator 5: Better Comments 6: CodeSnap
C# Syntactic Sugar: The Secret Ingredient
Переглядів 608Рік тому
Syntactic sugar is the secret ingredient that enables the C# compiler to add new features without needing to make changes to the underlying tooling, such as the CLR, JIT, AOT compiler and others. Link: sharplab.io
Visual Studio Code vs Visual Studio
Переглядів 177 тис.2 роки тому
Deciding on Visual Studio or Visual Studio Code is not just a personal decision but based on the best option for the operating system and application type you are building. VS Code: code.visualstudio.com/ Visual Code: visualstudio.microsoft.com/
Chunk your LINQ results in C#
Переглядів 5242 роки тому
Process your LINQ results in chunks by using this little known operator. Effective C# answers common questions about the C# language and the dotnet ecosystem. If you have a programming question about C# or .net then add it as a comment below. GitHub: github.com/ComponentFactory/CSharpAnswers
Add index to LINQ results in C#
Переглядів 4402 роки тому
You can add an index to the results of a LINQ query by using this simple trick. Effective C# answers common questions about the C# language and the dotnet ecosystem. If you have a programming question about C# or .net then add it as a comment below. GitHub: github.com/ComponentFactory/CSharpAnswers
Shuffle any list in C#
Переглядів 1,3 тис.2 роки тому
This handy LINQ extension method provides any easy way to shuffle any IEnumerable list of items. For example, values for a deck of cards or any other type in your application, such as Unity. Effective C# answers common questions about the C# language and the dotnet ecosystem. If you have a programming question about C# or .NET then add it as a comment below. GitHub: github.com/ComponentFactory/...
Compiler internals for the record type in C#
Переглядів 2412 роки тому
See the code the compiler generates for record types to really understand how they work in C#. C# Answers provides answers to common questions about the C# language and the related .NET system. Do you have a programming question about C# or .NET that you would like answered? Add it as a comment below and I try to answer them all! GitHub: github.com/ComponentFactory/CSharpAnswers
Using IDisposable in C#
Переглядів 3,2 тис.2 роки тому
Implement the IDisposable interface when you have managed or unmanaged resources that need cleaning up without waiting for the garbage collector to run. C# Answers provides answers to common questions about the C# language and the related .NET system. Do you have a programming question about C# or .NET that you would like answered? Add it as a comment below and I try to answer them all! Microso...
Paging results from LINQ in C#
Переглядів 5872 роки тому
You often need to add paging to a query so the application user can see the results in a table and then move page by page through the data. C# Answers provides answers to common questions about the C# language and the related .NET system. Do you have a programming question about C# or .NET that you would like answered? Add it as a comment below and I try to answer them all! GitHub: github.com/C...
GroupBy multiple properties in LINQ C#
Переглядів 2,8 тис.2 роки тому
Sometimes you need to perform a LINQ GroupBy using more than a single property. This video will demo how to do this in C#. C# Answers provides answers to common questions about the C# language and the related .NET system. Do you have a programming question about C# or .NET that you would like answered? Add it as a comment below and I try to answer them all! GitHub: github.com/ComponentFactory/C...
Required keyword in C# 11
Переглядів 2722 роки тому
The 'required' keyword allows you to reduce the boilerplate code in your projects by using object initialization. C# Answers provides answers to common questions about the C# language and the related .NET system. Do you have a programming question about C# or .NET that you would like answered? Add it as a comment below and I try to answer them all! GitHub: github.com/ComponentFactory/CSharpAnswers
Dynamic LINQ queries in C#
Переглядів 4,9 тис.2 роки тому
Sometimes you need to create a LINQ query that is dynamic and can be adapted to requirements such as responding to users clicking on different columns for sorting. C# Answers provides answers to common questions about the C# language and the related .NET system. Do you have a programming question about C# or .NET that you would like answered? Add it as a comment below and I try to answer them a...
Difference between IEnumerable and IQueryable in C#
Переглядів 2,9 тис.2 роки тому
Many developers use LINQ without knowing the real difference between these two important interfaces. C# Answers provides answers to common questions about the C# language and the related .NET system. Do you have a programming question about C# or .NET that you would like answered? Add it as a comment below and I try to answer them all! GitHub: github.com/ComponentFactory/CSharpAnswers
Join using multiple properties in LINQ in C#
Переглядів 4812 роки тому
Join using multiple properties in LINQ in C#
Left Outer Join in LINQ in C#
Переглядів 3,5 тис.2 роки тому
Left Outer Join in LINQ in C#
Difference between Select and SelectMany in LINQ in C#
Переглядів 6 тис.2 роки тому
Difference between Select and SelectMany in LINQ in C#
Multi property ordering, OrderBy, using LINQ in C#
Переглядів 6992 роки тому
Multi property ordering, OrderBy, using LINQ in C#
Create a multiline string in C#
Переглядів 4502 роки тому
Create a multiline string in C#
Raw string literal pattern in C# 11
Переглядів 1162 роки тому
Raw string literal pattern in C# 11
Differences between a field and a property in C#
Переглядів 6 тис.2 роки тому
Differences between a field and a property in C#
Sort a generic List by a property of the objects in C#
Переглядів 6 тис.2 роки тому
Sort a generic List by a property of the objects in C#
NullReferenceException and how do I fix it in C#
Переглядів 1,2 тис.2 роки тому
NullReferenceException and how do I fix it in C#
What do two question marks / null coalescing / '??' do in C#?
Переглядів 3812 роки тому
What do two question marks / null coalescing / '??' do in C#?
Generate a random number in C#
Переглядів 8642 роки тому
Generate a random number in C#
Best way to catch multiple exceptions in C#
Переглядів 2952 роки тому
Best way to catch multiple exceptions in C#
Deep clone/copy an object graph in C#
Переглядів 9782 роки тому
Deep clone/copy an object graph in C#
Iterate over a Dictionary in C#
Переглядів 5032 роки тому
Iterate over a Dictionary in C#
Case insensitive string.Contains in C#
Переглядів 9712 роки тому
Case insensitive string.Contains in C#