本文整理汇总了C#中System.String.First方法的典型用法代码示例。如果您正苦于以下问题:C# String.First方法的具体用法?C# String.First怎么用?C# String.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String
的用法示例。
在下文中一共展示了String.First方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArchiveGenerationParameters
/// <summary>
/// Initializes a new instance of the <see cref="ArchiveGenerationParameters"/> class.
/// </summary>
/// <param name="args">The application's command line arguments.</param>
public ArchiveGenerationParameters(String[] args)
{
if (args == null || !args.Any())
throw new InvalidCommandLineException();
var parser = new CommandLineParser(args);
if (!parser.IsParameter(args.First()))
throw new InvalidCommandLineException();
switch (args.First().ToLowerInvariant())
{
case "-pack":
Command = ArchiveGenerationCommand.Pack;
ProcessPackParameters(args, parser);
break;
case "-list":
Command = ArchiveGenerationCommand.List;
ProcessListParameters(args, parser);
break;
default:
throw new InvalidCommandLineException();
}
}
示例2: FontGenerationParameters
/// <summary>
/// Initializes a new instance of the <see cref="FontGenerationParameters"/> class.
/// </summary>
/// <param name="args">The application's command line arguments.</param>
public FontGenerationParameters(String[] args)
{
if (args == null || !args.Any())
throw new InvalidCommandLineException();
var parser = new CommandLineParser(args.Skip(1));
if (parser.IsParameter(args.First()))
{
throw new InvalidCommandLineException();
}
NoBold = parser.HasArgument("nobold");
NoItalic = parser.HasArgument("noitalic");
FontName = args.First();
FontSize = parser.GetArgumentOrDefault<Single>("fontsize", 16f);
Overhang = parser.GetArgumentOrDefault<Int32>("overhang", 0);
PadLeft = parser.GetArgumentOrDefault<Int32>("pad-left", 0);
PadRight = parser.GetArgumentOrDefault<Int32>("pad-right", 0);
SuperSamplingFactor = parser.GetArgumentOrDefault<Int32>("supersample", 2);
if (SuperSamplingFactor < 1)
SuperSamplingFactor = 1;
SourceText = parser.GetArgumentOrDefault<String>("sourcetext");
SourceFile = parser.GetArgumentOrDefault<String>("sourcefile");
SourceCulture = parser.GetArgumentOrDefault<String>("sourceculture");
if (SourceText != null && SourceFile != null)
throw new InvalidCommandLineException("Both a source text and a source file were specified. Pick one!");
SubstitutionCharacter = parser.GetArgumentOrDefault<Char>("sub", '?');
}
示例3: enqueueChatLine
public static void enqueueChatLine(String line)
{
ChatLine chat_line = new ChatLine(line);
//Check if the message has a name
if (line.Length > 3 && line.First() == '[')
{
int name_length = line.IndexOf(']');
if (name_length > 0)
{
name_length = name_length - 1;
String name = line.Substring(1, name_length);
if (name == "Server")
chat_line.color = new Color(0.65f, 1.0f, 1.0f);
else
chat_line.color = KLFVessel.generateActiveColor(name) * NAME_COLOR_SATURATION_FACTOR
+ Color.white * (1.0f-NAME_COLOR_SATURATION_FACTOR);
}
}
chatLineQueue.Enqueue(chat_line);
while (chatLineQueue.Count > MAX_CHAT_LINES)
chatLineQueue.Dequeue();
scrollPos.y += 100;
}
示例4: AIRCH
public AIRCH(String host, int port, String channel = "#terraria", String nick="IRCage", String username="IRCage", String realname="IRC support for TDSM",String nspass="", String pass = "", String quitMessage = "Bye bye!", String commandDelim = "+", bool ircColors=false)
{
this.host = host;
this.port = port;
this.nick = nick;
this.username = username;
this.realname = realname;
this.channel = channel;
this.nspass = nspass;
this.pass = pass;
this.quitMessage = quitMessage;
this.commandDelim = commandDelim.First();
this.ircColors = ircColors;
}
示例5: StartDirect
private static void StartDirect(String[] args)
{
try
{
Common.Initialize();
switch (args.First())
{
case "-game": Common.StartGame(args.Skip(1).ToArray()); break;
case "-editor": Common.StartEditor(args.Skip(1).ToArray()); break;
default: throw new ArgumentException(@"Invalid start argument: """ + args[0] + @""", valid arguments are ""-game"" or ""-editor""");
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), e.GetType().Name);
}
}
示例6: ToByteArray
public static Byte[] ToByteArray(String s)
{
BigInteger bi = 0;
// Decode base58
foreach (Char c in s)
{
int charVal = base58chars.IndexOf(c);
if (charVal >= 0)
{
bi *= 58;
bi += charVal;
}
}
Byte[] b = bi.ToByteArray();
// Remove 0x00 sign byte if present.
if (b[b.Length - 1] == 0x00)
b = b.Take(b.Length - 1).ToArray();
// Add leading 0x00 bytes
int num0s = s.IndexOf(s.First(c => c != '1'));
return b.Concat(new Byte[num0s]).Reverse().ToArray();
}
示例7: Line
public static void Line(String line)
{
ChatLine chatLine = new ChatLine(line);
if (line.Length > 3 && line.First() == '[')
{//Check if the message starts with name
int nameLength = line.IndexOf(']');
if (nameLength > 0)
{//render name colour
nameLength = nameLength - 1;
String name = line.Substring(1, nameLength);
if (name == "Server")
chatLine.Color = new Color(0.65f, 1.0f, 1.0f);
else
chatLine.Color =
KLFVessel.GenerateActiveColor(name) * NameColorSaturationFactor + Color.white * (1.0f - NameColorSaturationFactor);
}
}
ChatLineQueue.Enqueue(chatLine);
while (ChatLineQueue.Count > MaxChatLines)
ChatLineQueue.Dequeue();
ScrollPos.y += 100;
}
示例8: ChatLine
public ChatLine(String line)
{
this.color = Color.yellow;
this.name = "";
this.message = line;
//Check if the message has a name
if (line.Length > 3 && line.First() == '[')
{
int name_length = line.IndexOf(']');
if (name_length > 0)
{
name_length = name_length - 1;
this.name = line.Substring(1, name_length);
this.message = line.Substring(name_length + 2);
if (this.name == "Server")
this.color = Color.magenta;
else this.color = KMPVessel.generateActiveColor(name) * NAME_COLOR_SATURATION_FACTOR
+ Color.white * (1.0f - NAME_COLOR_SATURATION_FACTOR);
}
}
}
示例9: TrimNonLetterPrefix
public static String TrimNonLetterPrefix(String word)
{
var firstLetter = word.First(Char.IsLetter);
if (word.IndexOf(firstLetter) != 0)
return word.Substring(word.IndexOf(firstLetter));
else
return word;
}
示例10: ChatLine
public ChatLine(String line)
{
this.color = Color.yellow;
this.name = "";
this.message = line;
this.isAdmin = false;
//Check if the message has a name
if (line.Length > 3 && (line.First() == '<' || (line.StartsWith("["+KMPCommon.ADMIN_MARKER+"]") && line.Contains('<'))))
{
int name_start = line.IndexOf('<');
int name_end = line.IndexOf('>');
int name_length = name_end - name_start - 1;
if (name_length > 0)
{
this.name = line.Substring(name_start+1, name_length);
this.message = line.Substring(name_end + 1);
if (this.name == "Server")
this.color = Color.magenta;
else if (line.StartsWith("["+KMPCommon.ADMIN_MARKER+"]")) {
this.color = Color.red;
this.isAdmin = true;
} else this.color = KMPVessel.generateActiveColor(name) * NAME_COLOR_SATURATION_FACTOR
+ Color.white * (1.0f - NAME_COLOR_SATURATION_FACTOR);
}
}
}
示例11: GetConfigLine
private String[] GetConfigLine(String CompanyName, String UserName)
{
String[] RDConfigLine = new String[] { };
foreach (String RDConfiguration in RDConfigurations.Values)
{
if (!String.IsNullOrEmpty(RDConfiguration))
{
RDConfigLine = RDConfiguration.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
if ((RDConfigLine.First() == CompanyName) && (GetValue(RDConfigLine[1]) == UserName))
{
break;
}
}
}
return (RDConfigLine);
}
示例12: OpenFirmware
private void OpenFirmware(String[] Files)
{
if (Files == null) Source.OpenFirmware();
else Source.OpenFirmware(Files.First());
}
示例13: GetSelectedColRow
/// <summary>
/// Get current col & row based on cell name
/// </summary>
/// <param name="name">Cell selected</param>
/// <param name="col">Column number</param>
/// <param name="row">Row number</param>
private void GetSelectedColRow(String cellName, out int col, out int row)
{
int rowNum;
int.TryParse(cellName.Substring(1), out rowNum);
col = cellName.First<char>() - 'A';
row = rowNum - 1;
}
示例14: BuildSubfields
/// <summary>
/// The build subfields.
/// </summary>
/// <returns>The <see cref="bool" />.</returns>
private bool BuildSubfields()
{
var subFields = new String(this._arrayDescription.Skip(this._arrayDescription.LastIndexOf('*')).ToArray());
if (subFields.First() == '*')
{
this.RepeatingSubfields = true;
}
List<string> subfieldNames = subFields.Split('!').ToList();
foreach (string subField in subfieldNames)
{
this.SubFieldDefinitions.Add(new DdfSubFieldDefinition { Name = subField });
}
return true;
}
示例15: Text
/// <summary>
/// Creates a <see cref="TextExpression"/> that represents a string or a character from specified source string.
/// </summary>
/// <param name="symbols">The symbol table for the expression.</param>
/// <param name="text">The string which contains quoting characters..</param>
/// <returns>An <see cref="TextExpression"/> which generates a string or a character from specified string.</returns>
public static TextExpression Text(SymbolTable symbols, String text)
{
return String.IsNullOrEmpty(text) || text.First() != text.Last()
? Text(symbols, default(Char), text)
: Text(symbols, text.First(), text.Substring(1, text.Length - 2));
}