本文整理汇总了C#中String.EndsWith方法的典型用法代码示例。如果您正苦于以下问题:C# String.EndsWith方法的具体用法?C# String.EndsWith怎么用?C# String.EndsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String.EndsWith方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Match
// Determine if we have an application directory match.
private static bool Match(UrlParser url, String dir)
{
if(dir.EndsWith("/"))
{
dir = dir + "*";
}
else
{
dir = dir + "/*";
}
UrlParser parser = new UrlParser(dir);
return parser.Matches(url);
}
示例2: Parse
// Parse a value into an instance of this class.
public static DateTime Parse(String value)
{
if(value == null)
{
return DateTime.MinValue;
}
else if(value.EndsWith("Z"))
{
value = value.Substring(0, value.Length - 1) + "-00:00";
}
try
{
return DateTime.ParseExact
(value, formats, CultureInfo.InvariantCulture,
DateTimeStyles.None);
}
catch(Exception)
{
throw new RemotingException(_("Arg_InvalidSoapValue"));
}
}
示例3: Write
internal void Write(String str)
{
ASCIIEncoding m_enc = new ASCIIEncoding();
byte[] m_buf = new byte[1024];
if (!str.EndsWith("\r\n")) str += "\r\n";
m_buf = m_enc.GetBytes(str);
m_stream.Write(m_buf, 0, m_buf.Length);
}
示例4: GetDirName
private static String GetDirName(String fullPath)
{
Debug.Assert(fullPath != null);
String dirName = null;
if (fullPath.Length > 3)
{
String s = fullPath;
if (fullPath.EndsWith(Path.DirectorySeparatorChar))
{
s = fullPath.Substring(0, fullPath.Length - 1);
}
dirName = Path.GetFileName(s);
}
else
{
dirName = fullPath; // For rooted paths, like "c:\"
}
return dirName;
}
示例5: Write
private void Write(String str)
{
ASCIIEncoding encoding = new ASCIIEncoding();
if (!str.EndsWith("\r\n")) str += "\r\n";
byte[] bufferBytes = encoding.GetBytes(str);
_stream.Write(bufferBytes, 0, bufferBytes.Length);
}
示例6: IsSuffix
////////////////////////////////////////////////////////////////////////
//
// IsSuffix
//
// Determines whether suffix is a suffix of string. If suffix equals
// String.Empty, true is returned.
//
////////////////////////////////////////////////////////////////////////
public unsafe virtual bool IsSuffix(String source, String suffix, CompareOptions options)
{
if (source == null || suffix == null)
{
throw new ArgumentNullException((source == null ? nameof(source) : nameof(suffix)),
SR.ArgumentNull_String);
}
Contract.EndContractBlock();
if (suffix.Length == 0)
{
return (true);
}
if (source.Length == 0)
{
return false;
}
if (options == CompareOptions.OrdinalIgnoreCase)
{
return source.EndsWith(suffix, StringComparison.OrdinalIgnoreCase);
}
if (options == CompareOptions.Ordinal)
{
return source.EndsWith(suffix, StringComparison.Ordinal);
}
if ((options & ValidIndexMaskOffFlags) != 0)
{
throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options));
}
return EndsWith(source, suffix, options);
}
示例7:
// Determine if a SOAP action is valid for a method.
public static bool IsSoapActionValidForMethodBase
(String soapAction, MethodBase mb)
{
SoapMethodAttribute mattr;
int index, index2;
String typeName;
String mbTypeName;
String assembly;
bool hasAssembly;
// Remove quotes from the action name.
if(soapAction[0] == '"' && soapAction.EndsWith("\""))
{
soapAction = soapAction.Substring
(1, soapAction.Length - 2);
}
// If the action matches the attribute, then return true.
mattr = (SoapMethodAttribute)
InternalRemotingServices.GetCachedSoapAttribute(mb);
if(mattr.SoapAction == soapAction)
{
return true;
}
// Determine if the action matches the one registered
// with the method.
lock(typeof(SoapServices))
{
if(methodToAction != null)
{
String temp = (String)(methodToAction[mb]);
if(temp != null && temp == soapAction)
{
return true;
}
}
}
// Pull apart the action and check its components.
index = soapAction.IndexOf('#');
if(index != -1)
{
typeName = ExtractTypeName
(soapAction.Substring(0, index), out hasAssembly);
if(typeName != null)
{
if(hasAssembly)
{
assembly = mb.DeclaringType.Module
.Assembly.FullName;
index2 = assembly.IndexOf(',');
if(index2 != -1)
{
assembly = assembly.Substring(0, index2);
}
mbTypeName = mb.DeclaringType.FullName +
", " + assembly;
}
else
{
mbTypeName = mb.DeclaringType.FullName;
}
if(typeName == mbTypeName)
{
return (mb.Name == soapAction.Substring(index + 1));
}
}
}
// The action string is not valid.
return false;
}
示例8: Parse
// Parse a value into an instance of this class.
public static SoapTime Parse(String value)
{
if(value != null && value.EndsWith("Z"))
{
value = value.Substring(0, value.Length - 1) + "-00:00";
}
return new SoapTime(DateTime.ParseExact
(value, formats, CultureInfo.InvariantCulture,
DateTimeStyles.None));
}