Skip to content

Commit a7cecbc

Browse files
Names -> Keywords (#6933)
Replacing full type names with keywords when appropriate Files affected: Race2.cs, arrayasreadonly.cs, exists1.cs, exists2.cs, trueforall1.cs, trueforall2.cs, example1.cs, arraysegment.cs, stringlib.cs, example1.cs, bitstodbl.cs, toint32.cs, binary1.cs, format3.cs. See #6920
1 parent 5f55fbb commit a7cecbc

File tree

14 files changed

+43
-43
lines changed

14 files changed

+43
-43
lines changed

samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/Race2.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// <Snippet12>
1+
// <Snippet12>
22
using System;
33
using System.Collections.Concurrent;
44
using System.Threading;
55

66
public class Continent
77
{
8-
public String Name { get; set; }
8+
public string Name { get; set; }
99
public int Population { get; set; }
1010
public Decimal Area { get; set; }
1111
}
@@ -14,7 +14,7 @@ public class Example
1414
{
1515
static ConcurrentBag<Continent> continents = new ConcurrentBag<Continent>();
1616
static CountdownEvent gate;
17-
static String msg = String.Empty;
17+
static string msg = string.Empty;
1818

1919
public static void Main()
2020
{
@@ -45,9 +45,9 @@ public static void Main()
4545

4646
private static void PopulateContinents(Object obj)
4747
{
48-
String name = obj.ToString();
48+
string name = obj.ToString();
4949
lock(msg) {
50-
msg += String.Format("Adding '{0}' to the list.\n", name);
50+
msg += string.Format("Adding '{0}' to the list.\n", name);
5151
}
5252
var continent = new Continent();
5353
continent.Name = name;

samples/snippets/csharp/VS_Snippets_CLR_System/system.Array.AsReadOnly/CS/arrayasreadonly.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// The following example wraps an array in a read-only IList.
1+
// The following example wraps an array in a read-only IList.
22

33
// <Snippet1>
44
using System;
@@ -16,7 +16,7 @@ public static void Main() {
1616
PrintIndexAndValues( myArr );
1717

1818
// Create a read-only IList wrapper around the array.
19-
IList<String> myList = Array.AsReadOnly( myArr );
19+
IList<string> myList = Array.AsReadOnly( myArr );
2020

2121
// Display the values of the read-only IList.
2222
Console.WriteLine( "The read-only IList contains the following values:" );
@@ -50,7 +50,7 @@ public static void PrintIndexAndValues( String[] myArr ) {
5050
Console.WriteLine();
5151
}
5252

53-
public static void PrintIndexAndValues( IList<String> myList ) {
53+
public static void PrintIndexAndValues( IList<string> myList ) {
5454
for ( int i = 0; i < myList.Count; i++ ) {
5555
Console.WriteLine( " [{0}] : {1}", i, myList[i] );
5656
}

samples/snippets/csharp/VS_Snippets_CLR_System/system.ArraySegment/CS/arraysegment.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// The following code example passes an ArraySegment to a method.
1+
// The following code example passes an ArraySegment to a method.
22

33
// <Snippet1>
44
using System;
@@ -15,14 +15,14 @@ public static void Main() {
1515
PrintIndexAndValues( myArr );
1616

1717
// Define an array segment that contains the entire array.
18-
ArraySegment<String> myArrSegAll = new ArraySegment<String>( myArr );
18+
ArraySegment<string> myArrSegAll = new ArraySegment<string>( myArr );
1919

2020
// Display the contents of the ArraySegment.
2121
Console.WriteLine( "The first array segment (with all the array's elements) contains:" );
2222
PrintIndexAndValues( myArrSegAll );
2323

2424
// Define an array segment that contains the middle five values of the array.
25-
ArraySegment<String> myArrSegMid = new ArraySegment<String>( myArr, 2, 5 );
25+
ArraySegment<string> myArrSegMid = new ArraySegment<string>( myArr, 2, 5 );
2626

2727
// Display the contents of the ArraySegment.
2828
Console.WriteLine( "The second array segment (with the middle five elements) contains:" );
@@ -37,7 +37,7 @@ public static void Main() {
3737
PrintIndexAndValues( myArrSegMid );
3838
}
3939

40-
public static void PrintIndexAndValues( ArraySegment<String> arrSeg ) {
40+
public static void PrintIndexAndValues( ArraySegment<string> arrSeg ) {
4141
for ( int i = arrSeg.Offset; i < (arrSeg.Offset + arrSeg.Count); i++ ) {
4242
Console.WriteLine( " [{0}] : {1}", i, arrSeg.Array[i] );
4343
}

samples/snippets/csharp/VS_Snippets_CLR_System/system.BitConverter.Class/CS/example1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <Snippet3>
1+
// <Snippet3>
22
using System;
33

44
public class Example
@@ -8,7 +8,7 @@ public static void Main()
88
int value = -16;
99
Byte[] bytes = BitConverter.GetBytes(value);
1010

11-
// Convert bytes back to Int32.
11+
// Convert bytes back to int.
1212
int intValue = BitConverter.ToInt32(bytes, 0);
1313
Console.WriteLine("{0} = {1}: {2}",
1414
value, intValue,

samples/snippets/csharp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/CS/bitstodbl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//<Snippet1>
1+
//<Snippet1>
22
// Example of the BitConverter.Int64BitsToDouble method.
33
using System;
44

@@ -14,7 +14,7 @@ public static void LongBitsToDouble( long argument )
1414

1515
// Display the argument in hexadecimal.
1616
Console.WriteLine( formatter,
17-
String.Format( "0x{0:X16}", argument ), doubleValue );
17+
string.Format( "0x{0:X16}", argument ), doubleValue );
1818
}
1919

2020
public static void Main( )

samples/snippets/csharp/VS_Snippets_CLR_System/system.array.exists/cs/exists1.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <Snippet1>
1+
// <Snippet1>
22
using System;
33

44
public class Example
@@ -23,16 +23,16 @@ public static void Main()
2323

2424
public class StringSearcher
2525
{
26-
Char firstChar;
26+
char firstChar;
2727

28-
public StringSearcher(Char firstChar)
28+
public StringSearcher(char firstChar)
2929
{
30-
this.firstChar = Char.ToUpper(firstChar);
30+
this.firstChar = char.ToUpper(firstChar);
3131
}
3232

33-
public bool StartsWith(String s)
33+
public bool StartsWith(string s)
3434
{
35-
if (String.IsNullOrEmpty(s)) return false;
35+
if (string.IsNullOrEmpty(s)) return false;
3636

3737
if(s.Substring(0, 1).ToUpper() == firstChar.ToString())
3838
return true;

samples/snippets/csharp/VS_Snippets_CLR_System/system.array.exists/cs/exists2.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <Snippet2>
1+
// <Snippet2>
22
using System;
33

44
public class Example
@@ -18,7 +18,7 @@ public static void Main()
1818
Console.WriteLine("One or more names begin with '{0}': {1}",
1919
charToFind,
2020
Array.Exists(names,
21-
s => { if (String.IsNullOrEmpty(s))
21+
s => { if (string.IsNullOrEmpty(s))
2222
return false;
2323

2424
if (s.Substring(0, 1).ToUpper() == charToFind.ToString())

samples/snippets/csharp/VS_Snippets_CLR_System/system.array.trueforall/cs/trueforall1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <Snippet1>
1+
// <Snippet1>
22
using System;
33

44
public class Example
@@ -8,7 +8,7 @@ public static void Main()
88
String[] values = { "Y2K", "A2000", "DC2A6", "MMXIV", "0C3" };
99
if (Array.TrueForAll(values, value => {
1010
int s;
11-
return Int32.TryParse(value.Substring(value.Length - 1), out s); }
11+
return int.TryParse(value.Substring(value.Length - 1), out s); }
1212
))
1313
Console.WriteLine("All elements end with an integer.");
1414
else

samples/snippets/csharp/VS_Snippets_CLR_System/system.array.trueforall/cs/trueforall2.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <Snippet2>
1+
// <Snippet2>
22
using System;
33

44
public class Example
@@ -19,10 +19,10 @@ public static void Main()
1919
Console.WriteLine("Not all elements end with an integer.");
2020
}
2121

22-
private static bool EndsWithANumber(String value)
22+
private static bool EndsWithANumber(string value)
2323
{
2424
int s;
25-
return Int32.TryParse(value.Substring(value.Length - 1), out s);
25+
return int.TryParse(value.Substring(value.Length - 1), out s);
2626
}
2727
}
2828
// The example displays the following output:

samples/snippets/csharp/VS_Snippets_CLR_System/system.arraysegment.class/cs/example1.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <Snippet1>
1+
// <Snippet1>
22
using System;
33
using System.Collections.Generic;
44

@@ -10,10 +10,10 @@ public static void Main()
1010
"Ebenezer", "Francis", "Gilbert",
1111
"Henry", "Irving", "John", "Karl",
1212
"Lucian", "Michael" };
13-
var partNames = new ArraySegment<String>(names, 2, 5);
13+
var partNames = new ArraySegment<string>(names, 2, 5);
1414

15-
// Cast the ArraySegment object to an IList<String> and enumerate it.
16-
var list = (IList<String>) partNames;
15+
// Cast the ArraySegment object to an IList<string> and enumerate it.
16+
var list = (IList<string>) partNames;
1717
for (int ctr = 0; ctr <= list.Count - 1; ctr++)
1818
Console.WriteLine(list[ctr]);
1919
}

samples/snippets/csharp/VS_Snippets_CLR_System/system.badimageformatexception.class/cs/stringlib.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <Snippet2>
1+
// <Snippet2>
22
using System;
33

44
public class StringLib
@@ -31,7 +31,7 @@ public string ToProperCase(string title)
3131
else
3232
newWords[ctr] = words[ctr];
3333
}
34-
return String.Join(" ", newWords);
34+
return string.Join(" ", newWords);
3535
}
3636
}
3737
// Attempting to load the StringLib.dll assembly produces the following output:

samples/snippets/csharp/VS_Snippets_CLR_System/system.bitconverter.toint32/cs/toint32.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <Snippet1>
1+
// <Snippet1>
22
using System;
33

44
public class Example
@@ -26,7 +26,7 @@ private static string FormatBytes(Byte[] bytes)
2626
{
2727
string value = "";
2828
foreach (var byt in bytes)
29-
value += String.Format("{0:X2} ", byt);
29+
value += string.Format("{0:X2} ", byt);
3030

3131
return value;
3232
}

samples/snippets/csharp/VS_Snippets_CLR_System/system.boolean.structure/cs/binary1.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <Snippet1>
1+
// <Snippet1>
22
using System;
33

44
public class Example
@@ -20,8 +20,8 @@ public static void Main()
2020

2121
private static string GetBinaryString(Byte value)
2222
{
23-
String retVal = Convert.ToString(value, 2);
24-
return new String('0', 8 - retVal.Length) + retVal;
23+
string retVal = Convert.ToString(value, 2);
24+
return new string('0', 8 - retVal.Length) + retVal;
2525
}
2626
}
2727
// The example displays the following output:

samples/snippets/csharp/VS_Snippets_CLR_System/system.boolean.structure/cs/format3.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <Snippet5>
1+
// <Snippet5>
22
using System;
33
using System.Globalization;
44

@@ -12,7 +12,7 @@ public static void Main()
1212
CultureInfo culture = CultureInfo.CreateSpecificCulture(cultureName);
1313
BooleanFormatter formatter = new BooleanFormatter(culture);
1414

15-
String result = String.Format(formatter, "Value for '{0}': {1}", culture.Name, value);
15+
string result = string.Format(formatter, "Value for '{0}': {1}", culture.Name, value);
1616
Console.WriteLine(result);
1717
}
1818
}
@@ -38,7 +38,7 @@ public Object GetFormat(Type formatType)
3838
return null;
3939
}
4040

41-
public String Format(String fmt, Object arg, IFormatProvider formatProvider)
41+
public string Format(string fmt, Object arg, IFormatProvider formatProvider)
4242
{
4343
// Exit if another format provider is used.
4444
if (! formatProvider.Equals(this)) return null;

0 commit comments

Comments
 (0)