QUESTIONS

Tagged: c#

answers  0
views  31K
votes  4

[Snippet] How to Encrypt and Decrypt a string in C#  

Here is a code snippet to help you encrypt and decrypt a string in C#. The key is hardcoded, but in your own project you may want to read it from a secure store, or perhaps a config file or environmen ...
Apr 03, 2016
Sacchidananda Murthy
{ 63.9K - 6522 - 5 }
answers  1
views  7.5K
votes  1

[Question] Reading appsettings.json in a .NET Core console application  

I am using .NET Core to build a simple console application. However, I am stuck by not being able to read a few settings from an appsettings.json file. How do I go about doing this? From what I u ...
Apr 08, 2016
Obrad Józef
{ 76.3K - 7911 - 6 }
answers  1  
views  3.1K
votes  0

[Question] ASP.NET Core: setting Viewbag value in the OnActionExecuting method  

In ASP.NET Core (RC1) I am setting a ViewBag value in the OnActionExecuting method in a custom ActionFilter. This is the code: public override void OnActionExecuting(ActionExecutingContext filterCon ...
Apr 20, 2016
Jim Slater
{ 18.4K - 2840 - 3 }
answers  1
views  1.3K
votes  0

[Question] C#: best practice of when to use a var vs the actual type?  

Are there any best practices when declaring variable with respect to the use of var versus the actual type? What I have seen so far is that complex types and reference types are usually declared with ...
Apr 04, 2016
Lylou Josephs
{ 3,720 - 735 - 1 }
answers  0
views  1.1K
votes  0

[Article] Overriding the Equals() and GetHashCode() methods in C# - Part 1  

System.Object.Equals() virtual method The Equals() is a virtual method defined in the System.Object class. Since every class is implicitly derived from Object, it provides the Equals() method. publi ...
Apr 21, 2016
Gaime Sullivan
{ 2,040 - 399 - 0 }
answers  0
views  972
votes  0

[Article] Overriding the Equals() and GetHashCode() methods in C# - Part 2  

This is in continuation to Overriding the Equals() and GetHashCode() methods in C# - Part 1 System.Object.GetHashCode() virtual method This method returns a number for an object that assigned by the . ...
Apr 21, 2016
Gaime Sullivan
{ 2,040 - 399 - 0 }
answers  1
views  948
votes  1

[Question] How do I escape a double quote in a verbatim string literal?  

Is there is a way to escape embedded double quotes in a verbatim string in C#? I have a lengthy string literal that wraps several lines. Escaping the quotes with a back-slash \ (at the bottom) does no ...
Apr 08, 2016
Amita Mhari
{ 55 - 1 - 0 }
answers  0
views  810
votes  3

[Question] How to pass a parameter to a SQL IN clause with C#, SQL Server  

My database has two tables that have master-child relationship. They are School and Student. Each school can have any number of students. A user has selected a number of schools. Next, they want to ...
Apr 07, 2016
Cheng Cao
{ 64 - 1 - 0 }
answers  1
views  608
votes  2

[Snippet] C# Singleton design pattern example  

The Singleton design pattern is one of the original Gang of Four design patterns. It is designed to limit the number of instances of a class to just one. When would you want to use this? In fact, t ...
Apr 01, 2016
Luka König
{ 93 - 2 - 0 }
answers  0
views  576
votes  0

[Question] Fastest way to serialize a POCO to JSON and deserialize JSON to a POCO  

What is the fastest way to serialized a POCO object to a JSON string and deserialize a JSON string back to a POCO object? I have seen several libraries and implementations, but what counts for us is s ...
Apr 13, 2016
Klaus Wörner
{ 50 - 1 - 0 }
answers  0
views  503
votes  1

[Question] When to use 'ref' and 'out' keywords - specifically with strings?  

Generally, I understand the difference between passing parameters by value and by reference. I also somewhat understand the difference between ref and out keywords. A ref variable is passed by refere ...
Apr 02, 2016
Sabri 'Afif Safar
{ 55 - 1 - 0 }
answers  1  
views  488
votes  0

[Question] Best Regular Expression to Validate Modern Emails in C#  

I need the best regular expression for validating emails. They must support country extensions, like .ca, co.uk, tw, etc. And they must allow for new extensions, like .club, .online, .social, etc. ...
Apr 17, 2016
Hans Otto
{ 52 - 1 - 0 }
answers  1  
views  456
votes  1

[Question] Is there a difference between String and string in C#?  

Is there any difference whether I use string or String in my C# code? Or does the compiler map one to another?
Apr 04, 2016
Vivek Sandipa
{ 56 - 1 - 0 }
answers  0
views  454
votes  0

[Question] Creating nested TagHelpers in ASP.NET Core  

I am building a complex taghelper that can use functionality that is available in other taghelpers. Is there is way to do this? If so, is there is an example I can see?
Apr 04, 2016
Vipin Brar
{ 50 - 1 - 0 }
answers  0
views  451
votes  0

[Question] Dynamically combining multiple OrderBy clauses in LINQ  

Our application has a search screen in which users search a very large database with doctor and nurse records. They can specify: Search String Filters Sort Order Any combination is possible: somet ...
Apr 03, 2016
Tranter Cornell
{ 50 - 1 - 0 }
27  posts
You may also like
When to use 'ref' and 'out' keywords - specifically with strings?
Visual Studio 2015 F10 Debugger key not working
Horizontally centering a <div> inside another <div>
How to Encrypt and Decrypt a string in C#
Server Side Rendering in JavaScript?
Curlybrackets Software
The source code for Curlybrackets (C#/.NET/SQL Server) is available for purchase here. Start your own Q+A site now!

Easily create custom post types: messages, ideas, questions, tickets, whatever.

The Software Pack is a great place to start your corporate Q+A customer support site.