<p></p>
<ol> <li> C#? ?? ??? ??? ?? ?? ????? ??, ?? ?? ??, ?? ? ??? ???? ??? ??? ?? ??? ??? ???????. 2. ?? ??? ??? ?? ??? ???? ?? ??? ?? ??? ???? ?? ??? ?? ? ? ??? ?? ??? ?? ???? ?? ??? ???????. 3. ?? ? ?? ??? {name : "alice", ?? : {city : "nyc"}}? ?? ??? ???? ???? ?? ?? ???? ?? ??? ?????. 4. C# 9? ??? ?? ( =) ? ??? ?? (? ??? ??)? ????? ?? ??? ?? ? NOT?? ? ?? ??? ?? ?? ??? ?????. 5. C# 10? ?? ??? [1, 2, 3], [1, .. var rest]? ?? ??? ???? ?? ? ?? ?? ??? ????? ???? ??? ?????. 6. IS ???? ??, ??? ? ?? ??? ??? ?? ??? ????, ??? ?? ??? ?????? ??? ??? ?????? ?? ??? ?????. 7. ??? ???? ??? ??, ??, ?? ?? ?? ? ?? ??? ??? ????? ??? ????? ?????. 8. ? ?? ?? ?? ???? ? ???? ??? ???????. ??? ?? ??? ??? ? ????. ?? ?? ?? ???? ????? ??? ? ? ????. 9. ?? ???? ?? ?? ?? ? ??, ?? ???? API ?? ?? ? ?? ??? ?? ?? ?? ?? ?? ??? ?????. 10. ?? ???? ???? ?? ??? ???, ???? ???? ???? ?? ???? ????, ?? ?? ???? ???? ?? ??? ?? ??? ??? ?? ?????. </li> </ol> <p><img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/175769472236899.jpg" class="lazy" alt="?? C# ?? ?? : ??? ? ????"></p>
<p> C#? ?? ??? ?? ?? ???? ?? ? ?? ???? ????? ?? ? ?????. C# 7?? C# 8, 9 ? 10? ?? ???? ?? ??? ?? ???? ?? ??, ?? ?? ? ??? ??? ?? ???? ?? ?? ? ???? ??? ??? ? ????. ? ????? ?? ???? ?? ?? ?? ? ?? ?? ??? ????? ?? ?? ??? <strong>?? C# ?? ??</strong> ? ?? ?? ????.</p>
<hr>
<h3 id="??-??-?-?????"> 1. ?? ?? ? ??????</h3>
<p> ?? ??? ???? ??? ?? ?? ????? ???? ??? ?? ???? ?? ? ? ????. ??? ???? ?? <code>if-else</code> ?? <code>switch</code> ??? ??, ?? ??? ??, ? ? ??? ?? ?????. ??? ???, ??? ? ??? ??? ???? ? ??????.</p>
<p> <code>switch</code> ? ?? ?? ??? ?? ?????? ?? ??? ?????.</p>
<ul>
<li> <code>switch</code> ???</li>
<li> ?? <code>is</code>
</li>
<li> <code>if</code>
</li>
<li> <code>for</code> , ??? ??? <code>using</code> <code>while</code> (??? ?? ?????)</li>
</ul>
<p> ?? ??? ?????.</p>
<hr>
<h3 id="code-Deconstruct-code-????-??-??"> 2. <code>Deconstruct</code> ???? ?? ??</h3>
<p> ?? ?? ??? ?? ? ??? <strong>??</strong> ???. ?? ?? ??? ????? ?? <code>Deconstruct</code> ??? ?? ? ? ????.</p>
<h4 id="?-??-???-?????"> ? : ?? ??? ?????</h4><pre class='brush:php;toolbar:false;'> ?? ?? ??
{
?? ??? FirstName {get; ??; }
?? ??? ??? ?? {get; ??; }
?? int ?? {get; ??; }
public void deconstruct (Out String FirstName, Out String LastName, Out int age)
{
FirstName = FirstName;
lastName = lastName;
?? = ??;
}
}</pre><p> ?? ??? ?? ???? ??? ? ????.</p><pre class='brush:php;toolbar:false;'> var person = new Person {firstName = "John", lastName = "doe", age = 30};
if (??? ( "John", "Doe", int age)))))))
{
Console.WriteLine ($ "Hello John, {age {Age} ?????.");
}</pre><blockquote><p> ? <strong>??</strong> : ??? ??? <code>Deconstruct</code> ???? ?? ?? ?? ??? ???????.</p></blockquote><p> ??? ?? ? ?? ????.</p><pre class='brush:php;toolbar:false;'> var (? ??, ???, ??) = ??;</pre><p> ??? ???? ?? ??? ???? ?????.</p><hr /><h3 id="??-??-?-??-??"> 3. ?? ?? ? ?? ??</h3><p> ?? ??? ???? ?? ?? ? ?? ??? ???? ?? ??? ??? ???? ? ????. ??? ??? ? ??? ?? ??? ?? ?????.</p><h4 id="??????-?-C"> ?????? ? (C# 9)</h4><pre class='brush:php;toolbar:false;'> ?? ?? ?? (String Street, String City, String Country);
?? ?? ?? (??? ??, int id, ?? ??);</pre><p> ?? ?? ?? ? ??? ?????.</p><pre class='brush:php;toolbar:false;'> Employee Emp = New ( "Alice", 101, New ( "Main St", "NYC", "USA"));
??? ?? = EMP ???
{
{?? : "Alice", ?? : {City : "NYC"}} => "NYC? Alice",
{?? : {Country : "USA", City : Var City}} city.startswith ( "S") => $ "{City}", {City} ",
{wasse.country : "???"} => "???? ??? ?",
_ => "? ???"
};</pre><blockquote><p> ? <strong>?? ?? ??</strong> :</p><ul><li> ?? ?? ( <code>{ Name: "Alice" }</code> )</li><li> ?? ?? ( <code>Address: { City: "NYC" }</code> )</li><li> ??? ?? ?? ( <code>City: var city</code> )</li><li> ???? ?? ?? ? ?? ?? (???)</li></ul></blockquote><p> ? ??? ?? <code>if</code> ???? ?? ???? ???? ?????.</p><hr /><h3 id="???-?-??-??-C"> 4. ??? ? ?? ?? (C# 9)</h3><p> C# 9? ??? ?? ( <code><</code> , <code><=</code> , <code>></code> , <code>>=</code> )? ??? ?? ( <code>and</code> <code>or</code> <code>not</code> )? ??????. ??? <code>switch</code> ????? ?? ?? ??? ?????.</p><h4 id="?-??-??"> ? : ?? ??</h4><pre class='brush:php;toolbar:false;'> ??? ???? = ?? ???
{
<13 => "child",
> = 13 ? <18 => "??",
> = 18 ? <65 => "??",
> = 65 => "Senior",
_ => "??"
};</pre><p> ??? ????? <code>not</code> ??? ?? ????.</p><pre class='brush:php;toolbar:false;'> if (??? null? ??? ??? s? ??? "")
{
console.writeline ($ "??? ??? : {s}");
}</pre><p> ??? Verbose Null? ? ??? ?????.</p><blockquote><p> ? <strong>?</strong> : ?? ?? ?? ???? ????? <code>not ""</code> . <code>not null</code> ?? ???? ?????.</p></blockquote><hr /><h3 id="??-??-C"> 5. ?? ?? (C# 10)</h3><p> C# 10 ?? ? <strong>?? ???</strong> ???? ?? ?? ??? ??? ?? ? ? ????.</p><h4 id="?-??-??-??"> ? : ?? ?? ??</h4><pre class='brush:php;toolbar:false;'> int [] ?? = {1, 2, 3};
??? ?? = ?? ???
{
[1, 2, 3] => "??? ??",
[1, _, _] => "1"?? ?????.
[1 ,..
[] => "?",
[var first] => $ "?? ?? : {? ??}",
[_, _] => "? ??",
_ => "?? ?"
};</pre><ul><li> <code>_</code> ?? ??? ?????.</li><li> <code>..</code> ????? ????? (0 ??).</li><li> <code>var x</code> ???? ??? ?????.</li></ul><p> ?? ?? ??, DSL ?? ?? ??? ?? ?????.</p><hr /><h3 id="??-???-????-code-is-code-??"> 6. ?? ??? ???? <code>is</code> ??</h3><p> <code>is</code> ???? ?? ?? ??? ???? ?? ?? ? ?? ??? ???? ????.</p><h4 id="?-??-?-??"> ? : ?? ? ??</h4><pre class='brush:php;toolbar:false;'> ?? ? = getValue ();
if (value is list <int> [1, 2 ?? 3, ..])
{
Console.WriteLine ( "??? 1, 2 ?? 3?? ??);
}
if (?? string s??> = "apple"?? <= "mango")
{
Console.WriteLine ($ "??? ??? : {s}");
}</pre><blockquote><p> ?? <strong>??</strong> : <code>is</code> ? IS <code>and</code> ??? ?????. <code>is string s and not null</code> . <code>is not null and string s</code> ?? ??? ?? ????? ?? ? ????.</p></blockquote><p> ?? ? ???? ??? ??????.</p><pre class='brush:php;toolbar:false;'> if (?? (??? s)?? null? ??? "")</pre><hr /><h3 id="???-???-?-???-?"> 7. ??? ??? ? ??? ?</h3><p> ??? <strong>???</strong> (C# 8? ??)? ? ???? ??????.</p><h4 id="????-???-?"> ???? ??? ?</h4><pre class='brush:php;toolbar:false;'> ??? ??;
??? (??)
{
Case Circle C :
?? = "?";
????;
??? ??? R :
?? = "???";
????;
??:
?? = "? ???";
????;
}</pre><h4 id="??-???-??"> ?? ??? ??</h4><pre class='brush:php;toolbar:false;'> ??? ?? = ?? ???
{
? {?? :> 10} => "? ?",
? {?? : <= 10} => "?? ?",
??? {?? : var w, ?? : var h} w == h => "square",
??? _ => "???",
null => ??? ArgumentNullexception (nameof (shape)),
_ => "? ???"
};</pre><p> ?? :</p><ul><li> ??? ????</li><li> ??? ??</li><li> ?? ?? (?? ??)</li><li> ??? <code>when</code> ?????</li></ul><hr /><h3 id="??-??-??"> 8. ?? ?? ??</h3><p> ?? ??? ???? ??? ???? ???? ??? ??? ? ? ????.</p><h4 id="?"> ? :</h4><ul><li> ??? ?? ?? ??? ?????.</li><li> ??? ?? ? ? <code>if-is</code> ? ???? <code>switch</code> ???? ?????.</li><li> ????? ??? ???? ?? <code>is</code> .</li><li> ????? ??? ?? ??? <code>switch</code> ??? ?? ???? ??????.</li></ul><blockquote><p> ? <strong>?? ?? ?</strong> : ??? ?? ??? ??, ???? <code>Type</code> ??? ?? ??? ?? ? ? ????.</p></blockquote><p> ??? ???? ?? ???? ??? ??? ??? ?? ??? ?????.</p><hr /><h3 id="??-??-??"> 9. ?? ?? ??</h3><h4 id="strong-??-??-??-??-??-strong"> 1. <strong>?? ?? ?? ?? ??</strong></h4><pre class='brush:php;toolbar:false;'> Object [] args = { "-Verbose", "input.txt"};
var (Verbose, filename) = Args ???
{
[ "-verbose", ??? ??] => (true, file),
[??? ??] => (false, file),
_ => (??, ?)
};</pre><h4 id="strong-API-??-??-strong"> 2. <strong>API ?? ??</strong></h4><pre class='brush:php;toolbar:false;'> ?? ???
{
AccoundResponse {data : list <user> user} => displayUsers (???),
ErrorResponse {code : 404} => showOtFound (),
ErrorResponse {message : var msg} => ??? (msg),
_ => ??? InvalidOperationException () ??? ()
};</pre><h4 id="strong-??-??-??-??-??-strong"> 3. <strong>?? ?? ?? ?? ??</strong></h4><pre class='brush:php;toolbar:false;'> (Player.State, Enemy.state) ???
{
(playerstate.attacking, emystate.vulnerable) => DealDamage (),
(playerstate.defending, _) => redeDamage (),
(_, emperking.attacking) => playerTakedAmage (),
_ => ???? ?? ()
};</pre><hr>
<h3 id="????-???-??-??"> 10. ???? ??? ?? ??</h3>
<ul>
<li> <strong>?? ??? ?????</strong> : ???? ?? ? ?? ???? ????.</li>
<li> <strong><code>when</code> ? ???? ??</strong> : ???? ????? ??? ?? ? ????.</li>
</ul>
? ??? ?? C# ?? ?? : ??? ? ????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!