This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Stream stream = File.OpenRead("foo"); | |
| Console.WriteLine("Before using"); | |
| using (stream) | |
| { | |
| // Whatever... | |
| } | |
| Console.WriteLine("After using statement - variable is still in scope"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| static class Test | |
| { | |
| private static void Foo(this string text) | |
| { | |
| Console.WriteLine(text); | |
| } | |
| static void Main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| interface IFoo | |
| { | |
| void DoWork() | |
| { | |
| Console.WriteLine("Default implementation"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public boolean setVal(int v) { | |
| int oldVal = val; | |
| val = v; | |
| return oldVal != v; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Threading; | |
| struct Foo | |
| { | |
| private readonly int value; | |
| public Foo(int value) | |
| { | |
| this.value = value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| import java.text.*; | |
| public class Test { | |
| public static void main(String[] args) throws Exception { | |
| String text = "2020-05-05T09:30:00"; | |
| Locale locale = Locale.ROOT; | |
| SimpleDateFormat simpleDateFormat = new SimpleDateFormat( | |
| "yyyy-MM-dd'T'HH:mm:ss", locale); | |
| simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| M("foo"); | |
| M(new object()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Project Sdk="Microsoft.NET.Sdk"> | |
| <PropertyGroup> | |
| <OutputType>Exe</OutputType> | |
| <TargetFramework>netcoreapp3.1</TargetFramework> | |
| </PropertyGroup> | |
| <ItemGroup> | |
| <PackageReference Include="System.Buffers" Version="4.5.1" /> | |
| <PackageReference Include="System.Memory" Version="4.5.4" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| class Program | |
| { | |
| static void Main() | |
| { | |
| CaptureLoopVariable(); // Prints 5 5 5 5 5 | |
| CaptureCopyOfLoopVariable(); // Prints 0 1 2 3 4 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Collections.ObjectModel; | |
| using System.Linq; | |
| namespace LoopingEnumerable | |
| { | |
| public class Translation | |
| { | |
| public string TranslatedText { get; set; } |