Another usage of # operator in C#? [duplicate] - c#

This question already has answers here:
What's the use/meaning of the # character in variable names in C#?
(9 answers)
What does the # symbol before a variable name mean in C#? [duplicate]
(4 answers)
Closed 7 years ago.
I just found out something like this which works in C# code.
foreach (var item in list)
{
Console.WriteLine(#item);
}
Can anyone explain how is this possible - I have not found any documentation in ECMA for this.

Related

C# Check if a method exists in TDD [duplicate]

This question already has answers here:
How to check whether an object has certain method/property?
(5 answers)
Reflection GetMethod. select a more specific method
(3 answers)
Closed 11 months ago.
In Java I can check if a method named "addNumbers" exists in a class "Calculate" by doing this:
Class<?> c = Class.forName("com.example.package.Calculate");
Method m = c.getMethod("addNumbers", int.class, int.class);
m.invoke(5,7)
What is the C# equivalent for this example?

C# Generics, what does T<,> mean? [duplicate]

This question already has answers here:
Generics open and closed constructed types
(3 answers)
C# Language: generics, open/closed, bound/unbound, constructed
(2 answers)
Closed 3 years ago.
I have not seen this <,>-syntax before, and its impossible to google.
cfg.For(typeof(IPipelineBehavior<,>)).Add(typeof(OuterBehavior<,>));
.. I m guessing its some kind of wildcard, but I cant find any documentation
Source (for example)

Inline using how to make use of it [duplicate]

This question already has answers here:
Using statement question
(6 answers)
What are the uses of "using" in C#?
(29 answers)
Closed 4 years ago.
In C# one can type the using verb in line width the code sometimes, like
using (textwriter){ ..... }
I like that writing style and am wondered what is required to allow that for my own Api's.
As long as your objects are IDisposable then you can use it with the using statement.

VB to C# in InStrRev [duplicate]

This question already has answers here:
C# equivalent to InStrRev
(3 answers)
Closed 7 years ago.
I need to rewrite
Microsoft.VisualBasic.Strings.Mid(pReturn, (InstrRev(pReturn, ".") + 1), (pReturn).Length)).Length > 4
to C# but can't find a concise solution for InstrRev.
How can I convert this line?
String.LastIndexOf would be the equivalent.

How to declare an Optional type in C#? [duplicate]

This question already has answers here:
Optional return in C#.Net
(13 answers)
Closed 8 years ago.
Java 8 has Optional<T> which is nice way to declare optional types as described here.
Is there an equivalent way to that in C# ?
As per this answer You could make a struct that mimics this this type of functionality.

Categories