Skip to content

Commit 030c227

Browse files
Is it a useful change, to replace built-in types with keywords? (#6917)
* Batch 0-40 * fixes * fixes * fixes
1 parent ee75c3e commit 030c227

File tree

16 files changed

+38
-38
lines changed

16 files changed

+38
-38
lines changed

samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example4.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public static class StringLibrary
88
{
9-
public static int SubstringStartsAt(String fullString, String substr)
9+
public static int SubstringStartsAt(string fullString, string substr)
1010
{
1111
return fullString.IndexOf(substr, StringComparison.Ordinal);
1212
}
@@ -22,8 +22,8 @@ public class Example
2222
{
2323
public static void Main()
2424
{
25-
String value = "The archaeologist";
26-
String substring = "archæ";
25+
string value = "The archaeologist";
26+
string substring = "archæ";
2727
int position = StringLibrary.SubstringStartsAt(value, substring);
2828
if (position >= 0)
2929
Console.WriteLine("'{0}' found in '{1}' starting at position {2}",

samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example6.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public static class StringLibrary
88
{
9-
public static int SubstringStartsAt(String fullString, String substr)
9+
public static int SubstringStartsAt(string fullString, string substr)
1010
{
1111
return fullString.IndexOf(substr, StringComparison.CurrentCulture);
1212
}
@@ -22,8 +22,8 @@ public class Example
2222
{
2323
public static void Main()
2424
{
25-
String value = "The archaeologist";
26-
String substring = "archæ";
25+
string value = "The archaeologist";
26+
string substring = "archæ";
2727
int position = StringLibrary.SubstringStartsAt(value, substring);
2828
if (position >= 0)
2929
Console.WriteLine("'{0}' found in '{1}' starting at position {2}",

samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example8.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public static class StringLibrary
88
{
9-
public static int SubstringStartsAt(String fullString, String substr)
9+
public static int SubstringStartsAt(string fullString, string substr)
1010
{
1111
bool flag;
1212
if (AppContext.TryGetSwitch("StringLibrary.DoNotUseCultureSensitiveComparison", out flag) && flag == true)
@@ -26,8 +26,8 @@ public class Example
2626
{
2727
public static void Main()
2828
{
29-
String value = "The archaeologist";
30-
String substring = "archæ";
29+
string value = "The archaeologist";
30+
string substring = "archæ";
3131
int position = StringLibrary.SubstringStartsAt(value, substring);
3232
if (position >= 0)
3333
Console.WriteLine("'{0}' found in '{1}' starting at position {2}",

samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/GetSwitches3.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
public class Example
88
{
9-
private const String SettingName = "AppContextSwitchOverrides";
10-
private const String SwitchName = "Switch.Application.Utilities.SwitchName";
9+
private const string SettingName = "AppContextSwitchOverrides";
10+
private const string SwitchName = "Switch.Application.Utilities.SwitchName";
1111

1212
public static void Main()
1313
{
@@ -22,8 +22,8 @@ public static void Main()
2222

2323
ConfigurationSection sec = config.GetSection("runtime");
2424
if (sec != null) {
25-
String rawXml = sec.SectionInformation.GetRawXml();
26-
if (String.IsNullOrEmpty(rawXml)) return;
25+
string rawXml = sec.SectionInformation.GetRawXml();
26+
if (string.IsNullOrEmpty(rawXml)) return;
2727

2828
var doc = new XmlDocument();
2929
doc.LoadXml(rawXml);
@@ -34,11 +34,11 @@ public static void Main()
3434
if (node.Name.Equals(SettingName, StringComparison.Ordinal)) {
3535
// Get attribute value
3636
XmlAttribute attr = node.Attributes["value"];
37-
String[] nameValuePair = attr.Value.Split('=');
37+
string[] nameValuePair = attr.Value.Split('=');
3838
// Determine whether the switch we want is present.
3939
if (SwitchName.Equals(nameValuePair[0], StringComparison.Ordinal)) {
4040
bool tempFlag = false;
41-
if (Boolean.TryParse(CultureInfo.InvariantCulture.TextInfo.ToTitleCase(nameValuePair[1]),
41+
if (bool.TryParse(CultureInfo.InvariantCulture.TextInfo.ToTitleCase(nameValuePair[1]),
4242
out tempFlag))
4343
AppContext.SetSwitch(nameValuePair[0], tempFlag);
4444
}

samples/snippets/csharp/VS_Snippets_CLR_System/system.Action_PrintExample/cs/action.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Program
66
static void Main()
77
{
88
//<snippet01>
9-
List<String> names = new List<String>();
9+
List<string> names = new List<string>();
1010
names.Add("Bruce");
1111
names.Add("Alfred");
1212
names.Add("Tim");
@@ -17,7 +17,7 @@ static void Main()
1717

1818
// The following demonstrates the anonymous method feature of C#
1919
// to display the contents of the list to the console.
20-
names.ForEach(delegate(String name)
20+
names.ForEach(delegate(string name)
2121
{
2222
Console.WriteLine(name);
2323
});

samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~3/cs/Action3.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static void Main()
1010
Action<string[], string[], int> copyOperation = CopyStrings;
1111
copyOperation(ordinals, copiedOrdinals, 3);
1212
foreach (string ordinal in copiedOrdinals)
13-
Console.WriteLine(String.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
13+
Console.WriteLine(string.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
1414
}
1515

1616
private static void CopyStrings(string[] source, string[] target, int startPos)
@@ -19,7 +19,7 @@ private static void CopyStrings(string[] source, string[] target, int startPos)
1919
throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements.");
2020

2121
for (int ctr = startPos; ctr <= source.Length - 1; ctr++)
22-
target[ctr] = String.Copy(source[ctr]);
22+
target[ctr] = string.Copy(source[ctr]);
2323
}
2424
}
2525
// </Snippet2>

samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~3/cs/Anon.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static void Main()
1313
{ CopyStrings(s1, s2, pos); };
1414
copyOperation(ordinals, copiedOrdinals, 3);
1515
foreach (string ordinal in copiedOrdinals)
16-
Console.WriteLine(String.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
16+
Console.WriteLine(string.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
1717
}
1818

1919
private static void CopyStrings(string[] source, string[] target, int startPos)
@@ -22,7 +22,7 @@ private static void CopyStrings(string[] source, string[] target, int startPos)
2222
throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements.");
2323

2424
for (int ctr = startPos; ctr <= source.Length - 1; ctr++)
25-
target[ctr] = String.Copy(source[ctr]);
25+
target[ctr] = string.Copy(source[ctr]);
2626
}
2727
}
2828
// </Snippet3>

samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~3/cs/Delegate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void Main()
1414
StringCopy copyOperation = CopyStrings;
1515
copyOperation(ordinals, copiedOrdinals, 3);
1616
foreach (string ordinal in copiedOrdinals)
17-
Console.WriteLine(String.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
17+
Console.WriteLine(string.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
1818
}
1919

2020
private static void CopyStrings(string[] source, string[] target, int startPos)
@@ -23,7 +23,7 @@ private static void CopyStrings(string[] source, string[] target, int startPos)
2323
throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements.");
2424

2525
for (int ctr = startPos; ctr <= source.Length - 1; ctr++)
26-
target[ctr] = String.Copy(source[ctr]);
26+
target[ctr] = string.Copy(source[ctr]);
2727
}
2828
}
2929
// </Snippet1>

samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~3/cs/Lambda.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private static void CopyStrings(string[] source, string[] target, int startPos)
2020
throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements.");
2121

2222
for (int ctr = startPos; ctr <= source.Length - 1; ctr++)
23-
target[ctr] = String.Copy(source[ctr]);
23+
target[ctr] = string.Copy(source[ctr]);
2424
}
2525
}
2626
// </Snippet4>

samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Action4.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static void Main()
1111
Action<string[], string[], int, int> copyOperation = CopyStrings;
1212
copyOperation(ordinals, copiedOrdinals, 3, 5);
1313
foreach (string ordinal in copiedOrdinals)
14-
Console.WriteLine(String.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
14+
Console.WriteLine(string.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
1515
}
1616

1717
private static void CopyStrings(string[] source, string[] target,
@@ -21,7 +21,7 @@ private static void CopyStrings(string[] source, string[] target,
2121
throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements.");
2222

2323
for (int ctr = startPos; ctr <= startPos + number - 1; ctr++)
24-
target[ctr] = String.Copy(source[ctr]);
24+
target[ctr] = string.Copy(source[ctr]);
2525
}
2626
}
2727
// </Snippet2>

samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Anon.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void Main()
1414
{ CopyStrings(s1, s2, pos, num); };
1515
copyOperation(ordinals, copiedOrdinals, 3, 5);
1616
foreach (string ordinal in copiedOrdinals)
17-
Console.WriteLine(String.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
17+
Console.WriteLine(string.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
1818
}
1919

2020
private static void CopyStrings(string[] source, string[] target,
@@ -24,7 +24,7 @@ private static void CopyStrings(string[] source, string[] target,
2424
throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements.");
2525

2626
for (int ctr = startPos; ctr <= startPos + number - 1; ctr++)
27-
target[ctr] = String.Copy(source[ctr]);
27+
target[ctr] = string.Copy(source[ctr]);
2828
}
2929
}
3030
// </Snippet3>

samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Delegate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static void Main()
1616
StringCopy copyOperation = CopyStrings;
1717
copyOperation(ordinals, copiedOrdinals, 3, 5);
1818
foreach (string ordinal in copiedOrdinals)
19-
Console.WriteLine(String.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
19+
Console.WriteLine(string.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
2020
}
2121

2222
private static void CopyStrings(string[] source, string[] target,
@@ -26,7 +26,7 @@ private static void CopyStrings(string[] source, string[] target,
2626
throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements.");
2727

2828
for (int ctr = startPos; ctr <= startPos + number - 1; ctr++)
29-
target[ctr] = String.Copy(source[ctr]);
29+
target[ctr] = string.Copy(source[ctr]);
3030
}
3131
}
3232
// </Snippet1>

samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Lambda.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static void Main()
1212
=> CopyStrings(s1, s2, pos, num);
1313
copyOperation(ordinals, copiedOrdinals, 3, 5);
1414
foreach (string ordinal in copiedOrdinals)
15-
Console.WriteLine(String.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
15+
Console.WriteLine(string.IsNullOrEmpty(ordinal) ? "<None>" : ordinal);
1616
}
1717

1818
private static void CopyStrings(string[] source, string[] target,
@@ -22,7 +22,7 @@ private static void CopyStrings(string[] source, string[] target,
2222
throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements.");
2323

2424
for (int ctr = startPos; ctr <= startPos + number - 1; ctr++)
25-
target[ctr] = String.Copy(source[ctr]);
25+
target[ctr] = string.Copy(source[ctr]);
2626
}
2727
}
2828
// </Snippet4>

samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/CreateInstance5.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ public class Example
66
public static void Main()
77
{
88
// Initialize array of characters from a to z.
9-
Char[] chars = new Char[26];
9+
char[] chars = new char[26];
1010
for (int ctr = 0; ctr < 26; ctr++)
1111
chars[ctr] = (char) (ctr + 0x0061);
1212

13-
Object obj = Activator.CreateInstance(typeof(String),
14-
new Object[] { chars, 13, 10 } );
13+
object obj = Activator.CreateInstance(typeof(string),
14+
new object[] { chars, 13, 10 } );
1515
Console.WriteLine(obj);
1616
}
1717
}

samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/createinstance2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static void Main()
1212

1313
for (int ctr = 0; ctr <= arguments.GetUpperBound(0); ctr++) {
1414
object[] args = arguments[ctr];
15-
object result = Activator.CreateInstance(typeof(String), args);
15+
object result = Activator.CreateInstance(typeof(string), args);
1616
Console.WriteLine("{0}: {1}", result.GetType().Name, result);
1717
}
1818
}

samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/createinstanceex1a.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ public class Example
88
public static void Main()
99
{
1010
ObjectHandle handle = Activator.CreateInstance("PersonInfo", "Person");
11-
Object p = handle.Unwrap();
11+
object p = handle.Unwrap();
1212
Type t = p.GetType();
1313
PropertyInfo prop = t.GetProperty("Name");
1414
if (prop != null)
1515
prop.SetValue(p, "Samuel");
1616

1717
MethodInfo method = t.GetMethod("ToString");
18-
Object retVal = method.Invoke(p, null);
18+
object retVal = method.Invoke(p, null);
1919
if (retVal != null)
2020
Console.WriteLine(retVal);
2121
}

0 commit comments

Comments
 (0)