Skip to content

Commit d38731e

Browse files
author
Ron Petrusha
authored
Merge pull request #460 from dotnet/master
Update Live with current Master
2 parents f509de0 + 0e26ec2 commit d38731e

File tree

18 files changed

+805
-51
lines changed

18 files changed

+805
-51
lines changed

snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/customize1.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ public CList(IEnumerable<T> collection) : base(collection)
1010
public CList() : base()
1111
{}
1212

13-
public override String ToString()
13+
public override string ToString()
1414
{
15-
String retVal = String.Empty;
15+
string retVal = string.Empty;
1616
foreach (T item in this) {
17-
if (String.IsNullOrEmpty(retVal))
17+
if (string.IsNullOrEmpty(retVal))
1818
retVal += item.ToString();
1919
else
20-
retVal += String.Format(", {0}", item);
20+
retVal += string.Format(", {0}", item);
2121
}
2222
return retVal;
2323
}

snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/customize2.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44

55
public static class StringExtensions
66
{
7-
public static String ToString2<T>(this List<T> l)
7+
public static string ToString2<T>(this List<T> l)
88
{
9-
String retVal = String.Empty;
9+
string retVal = string.Empty;
1010
foreach (T item in l)
11-
retVal += String.Format("{0}{1}", String.IsNullOrEmpty(retVal) ?
11+
retVal += string.Format("{0}{1}", string.IsNullOrEmpty(retVal) ?
1212
"" : ", ",
1313
item);
14-
return String.IsNullOrEmpty(retVal) ? "{}" : "{ " + retVal + " }";
14+
return string.IsNullOrEmpty(retVal) ? "{}" : "{ " + retVal + " }";
1515
}
1616

17-
public static String ToString<T>(this List<T> l, String fmt)
17+
public static string ToString<T>(this List<T> l, string fmt)
1818
{
19-
String retVal = String.Empty;
19+
string retVal = string.Empty;
2020
foreach (T item in l) {
2121
IFormattable ifmt = item as IFormattable;
2222
if (ifmt != null)
23-
retVal += String.Format("{0}{1}",
24-
String.IsNullOrEmpty(retVal) ?
23+
retVal += string.Format("{0}{1}",
24+
string.IsNullOrEmpty(retVal) ?
2525
"" : ", ", ifmt.ToString(fmt, null));
2626
else
2727
retVal += ToString2(l);
2828
}
29-
return String.IsNullOrEmpty(retVal) ? "{}" : "{ " + retVal + " }";
29+
return string.IsNullOrEmpty(retVal) ? "{}" : "{ " + retVal + " }";
3030
}
3131
}
3232

snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/tostringoverload1.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
public class Automobile
55
{
66
private int _doors;
7-
private String _cylinders;
7+
private string _cylinders;
88
private int _year;
9-
private String _model;
9+
private string _model;
1010

11-
public Automobile(String model, int year , int doors,
12-
String cylinders)
11+
public Automobile(string model, int year , int doors,
12+
string cylinders)
1313
{
1414
_model = model;
1515
_year = year;
@@ -20,40 +20,40 @@ public Automobile(String model, int year , int doors,
2020
public int Doors
2121
{ get { return _doors; } }
2222

23-
public String Model
23+
public string Model
2424
{ get { return _model; } }
2525

2626
public int Year
2727
{ get { return _year; } }
2828

29-
public String Cylinders
29+
public string Cylinders
3030
{ get { return _cylinders; } }
3131

32-
public override String ToString()
32+
public override string ToString()
3333
{
3434
return ToString("G");
3535
}
3636

37-
public String ToString(String fmt)
37+
public string ToString(string fmt)
3838
{
39-
if (String.IsNullOrEmpty(fmt))
39+
if (string.IsNullOrEmpty(fmt))
4040
fmt = "G";
4141

4242
switch (fmt.ToUpperInvariant())
4343
{
4444
case "G":
45-
return String.Format("{0} {1}", _year, _model);
45+
return string.Format("{0} {1}", _year, _model);
4646
case "D":
47-
return String.Format("{0} {1}, {2} dr.",
47+
return string.Format("{0} {1}, {2} dr.",
4848
_year, _model, _doors);
4949
case "C":
50-
return String.Format("{0} {1}, {2}",
50+
return string.Format("{0} {1}, {2}",
5151
_year, _model, _cylinders);
5252
case "A":
53-
return String.Format("{0} {1}, {2} dr. {3}",
53+
return string.Format("{0} {1}, {2} dr. {3}",
5454
_year, _model, _doors, _cylinders);
5555
default:
56-
String msg = String.Format("'{0}' is an invalid format string",
56+
string msg = string.Format("'{0}' is an invalid format string",
5757
fmt);
5858
throw new ArgumentException(msg);
5959
}

snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/tostringoverload2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class Example
66
{
77
public static void Main()
88
{
9-
String[] cultureNames = { "en-US", "en-GB", "fr-FR",
9+
string[] cultureNames = { "en-US", "en-GB", "fr-FR",
1010
"hr-HR", "ja-JP" };
1111
Decimal value = 1603.49m;
1212
foreach (var cultureName in cultureNames) {

snippets/csharp/VS_Snippets_VBCSharp/csasyncexceptions/cs/class1.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ private async Task<string> DelayAsync()
7070
// Exception Message: canceled
7171
// Task IsCanceled: True
7272
// Task IsFaulted: False
73-
7473
//</Snippet2>
7574

7675

@@ -116,4 +115,4 @@ private async Task ExcAsync(string info)
116115
//</Snippet4>
117116
}
118117

119-
}
118+
}

snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsAccess/CS/csrefKeywordsAccess.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,25 @@ in BaseClass(int i)
9292
*/
9393
//</snippet2>
9494

95+
namespace Example1 //for redefinition of Employee
96+
{
97+
//<snippet4>
98+
public class Employee
99+
{
100+
private string alias;
101+
private string name;
102+
103+
public Employee(string name, string alias)
104+
{
105+
// Use this to qualify the members of the class
106+
// instead of the constructor parameters.
107+
this.name = name;
108+
this.alias = alias;
109+
}
110+
}
111+
//</snippet4>
112+
}
113+
95114
namespace Example2 //for redefinition of Employee
96115
{
97116
//<snippet3>
@@ -102,14 +121,13 @@ class Employee
102121
private decimal salary = 3000.00m;
103122

104123
// Constructor:
105-
//<snippet4>
106124
public Employee(string name, string alias)
107125
{
108126
// Use this to qualify the fields, name and alias:
109127
this.name = name;
110128
this.alias = alias;
111129
}
112-
//</snippet4>
130+
113131
// Printing method:
114132
public void printEmployee()
115133
{

snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsExceptions/CS/csrefKeywordsExceptions.cs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,34 @@ void ReadFile(int index)
3939

4040
//<snippet2>
4141
class TryFinallyTest
42-
{
43-
static void ProcessString(string s)
4442
{
45-
if (s == null)
43+
static void ProcessString(string s)
4644
{
47-
throw new ArgumentNullException();
45+
if (s == null)
46+
{
47+
throw new ArgumentNullException();
48+
}
4849
}
49-
}
5050

51-
static void Main()
52-
{
53-
string s = null; // For demonstration purposes.
54-
55-
try
56-
{
57-
ProcessString(s);
58-
}
59-
60-
catch (Exception e)
51+
static void Main()
6152
{
62-
Console.WriteLine("{0} Exception caught.", e);
53+
string s = null; // For demonstration purposes.
54+
55+
try
56+
{
57+
ProcessString(s);
58+
}
59+
catch (Exception e)
60+
{
61+
Console.WriteLine("{0} Exception caught.", e);
62+
}
6363
}
6464
}
65-
}
6665
/*
6766
Output:
6867
System.ArgumentNullException: Value cannot be null.
6968
at TryFinallyTest.Main() Exception caught.
7069
* */
71-
7270
//</snippet2>
7371

7472
//<snippet3>

snippets/csharp/programming-guide/discards/discard-pattern2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private static void ProvidesFormatInfo(object obj)
2121
Console.Write("A null object reference: ");
2222
Console.WriteLine("Its use could result in a NullReferenceException");
2323
}
24-
else if (obj is var _)
24+
else
2525
Console.WriteLine($"Some object type without format information");
2626
}
2727
}

windowsforms/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ If you're new to .NET Core, here are a few resources to help you understand the
1313
| Sample Name | Description |
1414
| ----------- | ----------- |
1515
| [Hello World - shared source](helloworld-sharedsource) | This sample shows you how to share source between a .NET Framework WinForms application and a .NET Core WinForms application. Use this to get the full .NET Framework tooling experience while still building for .NET Core. |
16+
| [Matching Game](matching-game) | This sample demonstrates simple event handling and timers in a .NET Core 3 WinForms application |
1617

1718
## Getting Started
1819

0 commit comments

Comments
 (0)