大约有 4,828 项符合查询结果(耗时:0.0238秒) [XML]
Identify if a string is a number
...
int n;
bool isNumeric = int.TryParse("123", out n);
Update As of C# 7:
var isNumeric = int.TryParse("123", out int n);
or if you don't need the number you can discard the out parameter
var isNumeric = int.TryParse("123", out _);
The var s can be replaced by their respective types!
...
Difference between is and as keyword
Please tell what is the difference between is and as keyword in C#
14 Answers
14
...
What is global::?
In C# I see global:: used quite often in auto-generated code. It is not something I have ever used myself so I don't know what the purpose is. Can someone explain this?
...
What is the Java equivalent for LINQ? [closed]
...t know if there is a JCP for it. LINQ necessitated several changes to the C# language, given the speed the JCP works at I wouldn't hold my breath.
– AgileJon
Aug 1 '09 at 23:14
12...
Type Checking: typeof, GetType, or is?
...s Foo)
Foo foo = (Foo)obj;
requires two.
Update (Jan 2020):
As of C# 7+, you can now cast inline, so the 'is' approach can now be done in one cast as well.
Example:
if(obj is Foo newLocalFoo)
{
// For example, you can now reference 'newLocalFoo' in this local scope
Console.WriteL...
How do I find the .NET version?
...
csc outputs the version of the C# compiler, not the version of the .NET Framework.
– Timwi
Aug 18 '11 at 15:17
4
...
A field initializer cannot reference the nonstatic field, method, or property
...
No, the compiler cannot rearrange the initializers. The C# Language Specification states, under the section "10.5.5.2 Instance field initialization", the following: The variable initializers are executed in the textual order in which they appear in the class declaration. This is e...
How do I import a namespace in Razor View Page?
...nse doesn't hint to add the using statement the same way it does in normal C# pages.
– Triynko
Sep 4 '15 at 22:15
|
show 3 more comments
...
What is the tilde (~) in the enum definition?
I'm always surprised that even after using C# for all this time now, I still manage to find things I didn't know about...
1...
How to create a simple proxy in C#?
...
I have recently written a light weight proxy in c# .net using TcpListener and TcpClient.
https://github.com/titanium007/Titanium-Web-Proxy
It supports secure HTTP the correct way, client machine needs to trust root certificate used by the proxy. Also supports WebSockets ...