Skip to content

Names -> Keywords batch 18 #6981

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 @@
// <Snippet2>
// <Snippet2>
using System;

public class Example
Expand All @@ -22,7 +22,7 @@ public static void Main()
}

// Encode the byte array using Base64 encoding
String base64 = Convert.ToBase64String(bytes);
string base64 = Convert.ToBase64String(bytes);
Console.WriteLine("The encoded string: ");
for (int ctr = 0; ctr <= base64.Length / 50; ctr++)
Console.WriteLine(base64.Substring(ctr * 50,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet1>
// <Snippet1>
using System;
using System.Globalization;

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

public class ChangeTypeTest {
Expand All @@ -7,15 +7,15 @@ public static void Main() {
Double d = -2.345;
int i = (int)Convert.ChangeType(d, TypeCode.Int32);

Console.WriteLine("The Double {0} when converted to an Int32 is {1}", d, i);
Console.WriteLine("The Double {0} when converted to an int is {1}", d, i);

string s = "12/12/2009";
DateTime dt = (DateTime)Convert.ChangeType(s, typeof(DateTime));

Console.WriteLine("The String {0} when converted to a Date is {1}", s, dt);
Console.WriteLine("The string {0} when converted to a Date is {1}", s, dt);
}
}
// The example displays the following output:
// The Double -2.345 when converted to an Int32 is -2
// The String 12/12/2009 when converted to a Date is 12/12/2009 12:00:00 AM
// The Double -2.345 when converted to an int is -2
// The string 12/12/2009 when converted to a Date is 12/12/2009 12:00:00 AM
// </Snippet2>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet3>
// <Snippet3>
using System;
using System.Globalization;

Expand Down Expand Up @@ -48,15 +48,15 @@ public bool ToBoolean(IFormatProvider provider)
public byte ToByte(IFormatProvider provider)
{
if (m_Temp < Byte.MinValue || m_Temp > Byte.MaxValue)
throw new OverflowException(String.Format("{0} is out of range of the Byte type.",
throw new OverflowException(string.Format("{0} is out of range of the Byte type.",
this.m_Temp));
else
return Decimal.ToByte(this.m_Temp);
}

public char ToChar(IFormatProvider provider)
{
throw new InvalidCastException("Temperature to Char conversion is not supported.");
throw new InvalidCastException("Temperature to char conversion is not supported.");
}

public DateTime ToDateTime(IFormatProvider provider)
Expand All @@ -77,16 +77,16 @@ public double ToDouble(IFormatProvider provider)
public short ToInt16(IFormatProvider provider)
{
if (this.m_Temp < Int16.MinValue || this.m_Temp > Int16.MaxValue)
throw new OverflowException(String.Format("{0} is out of range of the Int16 type.",
throw new OverflowException(string.Format("{0} is out of range of the Int16 type.",
this.m_Temp));
else
return Decimal.ToInt16(this.m_Temp);
}

public int ToInt32(IFormatProvider provider)
{
if (this.m_Temp < Int32.MinValue || this.m_Temp > Int32.MaxValue)
throw new OverflowException(String.Format("{0} is out of range of the Int32 type.",
if (this.m_Temp < int.MinValue || this.m_Temp > int.MaxValue)
throw new OverflowException(string.Format("{0} is out of range of the int type.",
this.m_Temp));
else
return Decimal.ToInt32(this.m_Temp);
Expand All @@ -95,7 +95,7 @@ public int ToInt32(IFormatProvider provider)
public long ToInt64(IFormatProvider provider)
{
if (this.m_Temp < Int64.MinValue || this.m_Temp > Int64.MaxValue)
throw new OverflowException(String.Format("{0} is out of range of the Int64 type.",
throw new OverflowException(string.Format("{0} is out of range of the Int64 type.",
this.m_Temp));
else
return Decimal.ToInt64(this.m_Temp);
Expand All @@ -104,7 +104,7 @@ public long ToInt64(IFormatProvider provider)
public sbyte ToSByte(IFormatProvider provider)
{
if (this.m_Temp < SByte.MinValue || this.m_Temp > SByte.MaxValue)
throw new OverflowException(String.Format("{0} is out of range of the SByte type.",
throw new OverflowException(string.Format("{0} is out of range of the SByte type.",
this.m_Temp));
else
return Decimal.ToSByte(this.m_Temp);
Expand Down Expand Up @@ -146,7 +146,7 @@ public object ToType(Type conversionType, IFormatProvider provider)
if (typeof(Temperature).Equals(conversionType))
return this;
else
throw new InvalidCastException(String.Format("Conversion to a {0} is not supported.",
throw new InvalidCastException(string.Format("Conversion to a {0} is not supported.",
conversionType.Name));
case TypeCode.SByte:
return this.ToSByte(null);
Expand All @@ -161,14 +161,14 @@ public object ToType(Type conversionType, IFormatProvider provider)
case TypeCode.UInt64:
return this.ToUInt64(null);
default:
throw new InvalidCastException(String.Format("Conversion to {0} is not supported.", conversionType.Name));
throw new InvalidCastException(string.Format("Conversion to {0} is not supported.", conversionType.Name));
}
}

public ushort ToUInt16(IFormatProvider provider)
{
if (this.m_Temp < UInt16.MinValue || this.m_Temp > UInt16.MaxValue)
throw new OverflowException(String.Format("{0} is out of range of the UInt16 type.",
throw new OverflowException(string.Format("{0} is out of range of the UInt16 type.",
this.m_Temp));
else
return Decimal.ToUInt16(this.m_Temp);
Expand All @@ -177,7 +177,7 @@ public ushort ToUInt16(IFormatProvider provider)
public uint ToUInt32(IFormatProvider provider)
{
if (this.m_Temp < UInt32.MinValue || this.m_Temp > UInt32.MaxValue)
throw new OverflowException(String.Format("{0} is out of range of the UInt32 type.",
throw new OverflowException(string.Format("{0} is out of range of the UInt32 type.",
this.m_Temp));
else
return Decimal.ToUInt32(this.m_Temp);
Expand All @@ -186,7 +186,7 @@ public uint ToUInt32(IFormatProvider provider)
public ulong ToUInt64(IFormatProvider provider)
{
if (this.m_Temp < UInt64.MinValue || this.m_Temp > UInt64.MaxValue)
throw new OverflowException(String.Format("{0} is out of range of the UInt64 type.",
throw new OverflowException(string.Format("{0} is out of range of the UInt64 type.",
this.m_Temp));
else
return Decimal.ToUInt64(this.m_Temp);
Expand All @@ -200,10 +200,10 @@ public class Example
public static void Main()
{
Temperature cool = new Temperature(5);
Type[] targetTypes = { typeof(SByte), typeof(Int16), typeof(Int32),
Type[] targetTypes = { typeof(SByte), typeof(Int16), typeof(int),
typeof(Int64), typeof(Byte), typeof(UInt16),
typeof(UInt32), typeof(UInt64), typeof(Decimal),
typeof(Single), typeof(Double), typeof(String) };
typeof(Single), typeof(Double), typeof(string) };
CultureInfo provider = new CultureInfo("fr-FR");

foreach (Type targetType in targetTypes)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet7>
// <Snippet7>
using System;

public class Example
Expand Down