Skip to content

Names -> Keywords batch 16 #6979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Specialized;

Expand All @@ -11,7 +11,7 @@ public DerivedCollection() {
// Adds elements from an IDictionary into the new collection.
public DerivedCollection( IDictionary d, Boolean bReadOnly ) {
foreach ( DictionaryEntry de in d ) {
this.BaseAdd( (String) de.Key, de.Value );
this.BaseAdd( (string) de.Key, de.Value );
}
this.IsReadOnly = bReadOnly;
}
Expand All @@ -25,7 +25,7 @@ public DictionaryEntry this[ int index ] {
}

// Gets or sets the value associated with the specified key.
public Object this[ String key ] {
public Object this[ string key ] {
get {
return( this.BaseGet( key ) );
}
Expand All @@ -34,7 +34,7 @@ public Object this[ String key ] {
}
}

// Gets a String array that contains all the keys in the collection.
// Gets a string array that contains all the keys in the collection.
public String[] AllKeys {
get {
return( this.BaseGetAllKeys() );
Expand All @@ -48,7 +48,7 @@ public Array AllValues {
}
}

// Gets a String array that contains all the values in the collection.
// Gets a string array that contains all the values in the collection.
public String[] AllStringValues {
get {
return( (String[]) this.BaseGetAllValues( typeof( string ) ));
Expand All @@ -63,12 +63,12 @@ public Boolean HasKeys {
}

// Adds an entry to the collection.
public void Add( String key, Object value ) {
public void Add( string key, Object value ) {
this.BaseAdd( key, value );
}

// Removes an entry with the specified key from the collection.
public void Remove( String key ) {
public void Remove( string key ) {
this.BaseRemove( key );
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The following code example demonstrates several of the properties and methods of NameValueCollection.
// The following code example demonstrates several of the properties and methods of NameValueCollection.

// <snippet1>
using System;
Expand Down Expand Up @@ -31,7 +31,7 @@ public static void Main() {
String[] myStrArr = new String[myCol.Count];
myCol.CopyTo( myStrArr, 0 );
Console.WriteLine( "The string array contains:" );
foreach ( String s in myStrArr )
foreach ( string s in myStrArr )
Console.WriteLine( " {0}", s );
Console.WriteLine();

Expand All @@ -48,7 +48,7 @@ public static void Main() {

public static void PrintKeysAndValues( NameValueCollection myCol ) {
Console.WriteLine( " KEY VALUE" );
foreach ( String s in myCol.AllKeys )
foreach ( string s in myCol.AllKeys )
Console.WriteLine( " {0,-10} {1}", s, myCol[s] );
Console.WriteLine();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet1>
// <Snippet1>
using System;

public class CityInfo
Expand All @@ -25,7 +25,7 @@ public int Population

public static int CompareByName(CityInfo city1, CityInfo city2)
{
return String.Compare(city1.City, city2.City);
return string.Compare(city1.City, city2.City);
}

public static int CompareByPopulation(CityInfo city1, CityInfo city2)
Expand All @@ -35,7 +35,7 @@ public static int CompareByPopulation(CityInfo city1, CityInfo city2)

public static int CompareByNames(CityInfo city1, CityInfo city2)
{
return String.Compare(city1.Country + city1.City, city2.Country + city2.City);
return string.Compare(city1.Country + city1.City, city2.Country + city2.City);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet1>
// <Snippet1>
using System;

public class Example
Expand All @@ -23,7 +23,7 @@ private static void WriteCharacterStrings(int start, int end,
if (changeColor)
Console.BackgroundColor = (ConsoleColor) ((ctr - 1) % 16);

Console.WriteLine(new String((char)(ctr + 64), 30));
Console.WriteLine(new string((char)(ctr + 64), 30));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dump a range of Unicode characters as a 16x16 array
// dump a range of Unicode characters as a 16x16 array
// <Snippet4>
using System;
using System.IO;
Expand Down Expand Up @@ -26,10 +26,10 @@ private static void Main(string[] args)
break;
case 3:
if (! uint.TryParse(args[0], NumberStyles.HexNumber, null, out rangeStart))
throw new ArgumentException(String.Format("{0} is not a valid hexadecimal number.", args[0]));
throw new ArgumentException(string.Format("{0} is not a valid hexadecimal number.", args[0]));

if (!uint.TryParse(args[1], NumberStyles.HexNumber, null, out rangeEnd))
throw new ArgumentException(String.Format("{0} is not a valid hexadecimal number.", args[1]));
throw new ArgumentException(string.Format("{0} is not a valid hexadecimal number.", args[1]));

bool.TryParse(args[2], out setOutputEncodingToUnicode);
break;
Expand All @@ -46,9 +46,9 @@ private static void Main(string[] args)
// This won't work before .NET Framework 4.5.
try {
// Set encoding using endianness of this system.
// We're interested in displaying individual Char objects, so
// We're interested in displaying individual char objects, so
// we don't want a Unicode BOM or exceptions to be thrown on
// invalid Char values.
// invalid char values.
Console.OutputEncoding = new UnicodeEncoding(! BitConverter.IsLittleEndian, false);
Console.WriteLine("\nOutput encoding set to UTF-16");
}
Expand Down Expand Up @@ -87,15 +87,15 @@ public static void DisplayRange(uint start, uint end)

// Check whether the start or end range is outside of last plane.
if (start > upperRange)
throw new ArgumentException(String.Format("0x{0:X5} is outside the upper range of Unicode code points (0x{1:X5})",
throw new ArgumentException(string.Format("0x{0:X5} is outside the upper range of Unicode code points (0x{1:X5})",
start, upperRange));
if (end > upperRange)
throw new ArgumentException(String.Format("0x{0:X5} is outside the upper range of Unicode code points (0x{0:X5})",
throw new ArgumentException(string.Format("0x{0:X5} is outside the upper range of Unicode code points (0x{0:X5})",
end, upperRange));

// Since we're using 21-bit code points, we can't use U+D800 to U+DFFF.
if ((start < surrogateStart & end > surrogateStart) || (start >= surrogateStart & start <= surrogateEnd ))
throw new ArgumentException(String.Format("0x{0:X5}-0x{1:X5} includes the surrogate pair range 0x{2:X5}-0x{3:X5}",
throw new ArgumentException(string.Format("0x{0:X5}-0x{1:X5} includes the surrogate pair range 0x{2:X5}-0x{3:X5}",
start, end, surrogateStart, surrogateEnd));
uint last = RoundUpToMultipleOf(0x10, end);
uint first = RoundDownToMultipleOf(0x10, start);
Expand All @@ -116,7 +116,7 @@ public static void DisplayRange(uint start, uint end)
}
else {
// the cast to int is safe, since we know that val <= upperRange.
String chars = Char.ConvertFromUtf32( (int) cur);
string chars = char.ConvertFromUtf32( (int) cur);
// Display a space for code points that are not valid characters.
if (CharUnicodeInfo.GetUnicodeCategory(chars[0]) ==
UnicodeCategory.OtherNotAssigned)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet5>
// <Snippet5>
using System;
using System.IO;

Expand All @@ -8,7 +8,7 @@ public static void Main()
{
char[] chars = { '\u0061', '\u0308' };

string combining = new String(chars);
string combining = new string(chars);
Console.WriteLine(combining);

combining = combining.Normalize();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// <Snippet1>
// <Snippet1>
using System;

public class Example
{
public static void Main()
{
// Create a Char array for the modern Cyrillic alphabet,
// Create a char array for the modern Cyrillic alphabet,
// from U+0410 to U+044F.
int nChars = 0x044F - 0x0410 + 1;
char[] chars = new char[nChars];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet1>
// <Snippet1>
using System;

public class Example
Expand All @@ -15,7 +15,7 @@ public static void Main()
ConsoleColor newForeColor = ConsoleColor.White;
ConsoleColor newBackColor = ConsoleColor.Black;

Char foreColorSelection = GetKeyPress("Select Text Color (B for Blue, R for Red, Y for Yellow): ",
char foreColorSelection = GetKeyPress("Select Text Color (B for Blue, R for Red, Y for Yellow): ",
new Char[] { 'B', 'R', 'Y' } );
switch (foreColorSelection) {
case 'B':
Expand All @@ -31,7 +31,7 @@ public static void Main()
newForeColor = ConsoleColor.DarkYellow;
break;
}
Char backColorSelection = GetKeyPress("Select Background Color (W for White, G for Green, M for Magenta): ",
char backColorSelection = GetKeyPress("Select Background Color (W for White, G for Green, M for Magenta): ",
new Char[] { 'W', 'G', 'M' });
switch (backColorSelection) {
case 'W':
Expand All @@ -50,13 +50,13 @@ public static void Main()

Console.WriteLine();
Console.Write("Enter a message to display: ");
String textToDisplay = Console.ReadLine();
string textToDisplay = Console.ReadLine();
Console.WriteLine();
Console.ForegroundColor = newForeColor;
Console.BackgroundColor = newBackColor;
Console.WriteLine(textToDisplay);
Console.WriteLine();
if (Char.ToUpper(GetKeyPress("Display another message (Y/N): ", new Char[] { 'Y', 'N' } )) == 'N')
if (char.ToUpper(GetKeyPress("Display another message (Y/N): ", new Char[] { 'Y', 'N' } )) == 'N')
continueFlag = false;

// Restore the default settings and clear the screen.
Expand All @@ -66,7 +66,7 @@ public static void Main()
} while (continueFlag);
}

private static Char GetKeyPress(String msg, Char[] validChars)
private static char GetKeyPress(string msg, Char[] validChars)
{
ConsoleKeyInfo keyPressed;
bool valid = false;
Expand All @@ -76,7 +76,7 @@ private static Char GetKeyPress(String msg, Char[] validChars)
Console.Write(msg);
keyPressed = Console.ReadKey();
Console.WriteLine();
if (Array.Exists(validChars, ch => ch.Equals(Char.ToUpper(keyPressed.KeyChar))))
if (Array.Exists(validChars, ch => ch.Equals(char.ToUpper(keyPressed.KeyChar))))
valid = true;
} while (! valid);
return keyPressed.KeyChar;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet1>
// <Snippet1>
using System;

public class Example
Expand Down Expand Up @@ -27,12 +27,12 @@ public static void Main()
increment += 10;
Console.Error.Write("Display multiples of {0} through {1} (y/n)? ",
increment + 1, increment + 10);
Char response = Console.ReadKey(true).KeyChar;
char response = Console.ReadKey(true).KeyChar;
Console.Error.WriteLine(response);
if (! Console.IsOutputRedirected)
Console.CursorTop--;

if (Char.ToUpperInvariant(response) == 'N')
if (char.ToUpperInvariant(response) == 'N')
exitFlag = true;
}
}
Expand Down