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
try | |
{ | |
DoSomeHttpRequest(); | |
} | |
catch (System.Web.HttpException e) if (e.GetHttpCode() == 400) | |
{ | |
WriteLine("Not Found"); | |
} | |
catch (System.Web.HttpException e) if (e.GetHttpCode() == 500) | |
{ |
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
try | |
{ | |
DoSomeHttpRequest(); | |
} | |
catch (System.Web.HttpException e) | |
{ | |
switch (e.GetHttpCode()) | |
{ | |
case 400: | |
WriteLine("Bad Request"); |
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.Console; | |
... | |
if (bool.TryParse("true", out var result)) | |
{ | |
WriteLine("This is a bool with value. " + result); | |
} | |
else | |
{ |
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
bool flag; | |
if (bool.TryParse("true", out flag)) | |
{ | |
Console.WriteLine("This is a bool with value. " + flag); | |
} | |
else | |
{ | |
Console.WriteLine("Not a bool, yo! " + flag); | |
} |
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
if (bool.TryParse("true", out var result)) | |
{ | |
Console.WriteLine("This is a bool with value. " + result); | |
} | |
else | |
{ | |
Console.WriteLine("Not a bool, yo! " + result); | |
} |
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
bool result; | |
if (bool.TryParse("true", out result)) | |
{ | |
Console.WriteLine("This is a bool with value. " + result); | |
} | |
else | |
{ | |
Console.WriteLine("Not a bool, yo! " + result); | |
} |
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 class Movie | |
{ | |
private readonly string <Title>k__BackingField | |
private readonly List<string> <Genres>k__BackingField; | |
private readonly int <Runtime>k__BackingField | |
public string Title | |
{ | |
get { return this.<Title>k__BackingField; } | |
} |
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 class Movie(string title, List<string> genres) | |
{ | |
public string Title { get; } = title; | |
public List<string> Genres { get; } = genres; | |
public int Runtime { get; private set; } | |
public Movie(string title, List<string> genres, int runtime) : this(title, genres) | |
{ |
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 class Movie | |
{ | |
private readonly string <Title>k__BackingField | |
private readonly List<string> <Genres>k__BackingField; | |
public string Title | |
{ | |
get { return this.<Title>k__BackingField; } | |
} | |
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 class Movie(string title, List<string> genres) | |
{ | |
public string Title { get; } = title; | |
public List<string> Genres { get; } = genres; | |
} |