本文整理汇总了C#中System.String.length方法的典型用法代码示例。如果您正苦于以下问题:C# String.length方法的具体用法?C# String.length怎么用?C# String.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String
的用法示例。
在下文中一共展示了String.length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: makeStringSize
private String makeStringSize(String str, int nSize)
{
if ( str.length() >= nSize )
return str.substring(0, nSize);
else {
String res = "";
for( int i = 0; i < nSize - str.length(); i++ )
res += ' ';
res += str;
return res;
}
}
示例2: checkSecurityAccess
public void checkSecurityAccess(String target)
{
if (null == target) throw new java.lang.NullPointerException();
if (0 == target.length()) throw new IllegalArgumentException();
// Here can be some security checks and if it fails, throw a new SecurityException
}
示例3: getRelativePath
static public String getRelativePath(String path1, String path2)
{
if (!path1.startsWith(path2))
return path1;
return path1.substring(path2.length());
}
示例4: writeString
public void writeString(String data)
{
if (!isOpened())
return;
m_st.Write(new UTF8Encoding().GetBytes(data), 0, data.length());
}
示例5: urlEncode
public static String urlEncode(String fullPath)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int len = fullPath.length();
char c;
for (int index = 0; index < len; index++)
{
c = fullPath.charAt(index);
if (c == '^' || c == '_'
|| c == '\\' || c == '-'
|| c == '.'
|| (c >= 'A' && c <= 'Z')
|| (c >= 'a' && c <= 'z')
|| (c >= '0' && c <= '9'))
{
sb.Append(c);
}
else
{
sb.Append('%');
sb.Append(String.Format("{0:X2}", (int)c));
}
}
return sb.ToString();
}
示例6: cancelRequest
public void cancelRequest(String szCallback)
{
if (szCallback == null || szCallback.length() == 0 )
{
LOG.INFO("Cancel callback should not be empty. Use * for cancel all");
return;
}
lock(getCommandLock())
{
HttpCommand pCmd = (HttpCommand)getCurCommand();
if ( pCmd != null && ( szCallback.compareTo("*") == 0 || pCmd.m_strCallback.compareTo(szCallback) == 0) )
pCmd.cancel();
if ( szCallback.compareTo("*") == 0 )
getCommands().Clear();
else
{
for (int i = getCommands().size()-1; i >= 0; i--)
{
HttpCommand pCmd1 = (HttpCommand)getCommands().get(i);
if ( pCmd1 != null && pCmd1.m_strCallback.compareTo(szCallback) == 0 )
getCommands().RemoveAt(i);
}
}
}
}
示例7: asciiEndsWithIgnoreCase
/**
* Returns whether the given source string ends with the suffix, ignoring
* case and assuming that the strings are ascii encoded.
*
* @param source
* the string to match.
* @param suffix
* the suffix to test.
* @return {@code true} if the source does end with the given suffix, or
* {@code false} if not.
*/
public static bool asciiEndsWithIgnoreCase(String source, String suffix)
{
int length = suffix.length();
if (length > source.length()) {
return false;
}
int offset = source.length() - length;
for (int i = 0; i < length; i++) {
char c1 = source.charAt(i + offset);
char c2 = suffix.charAt(i);
if (c1 != c2 && toASCIIUpperCase(c1) != toASCIIUpperCase(c2)) {
return false;
}
}
return true;
}
示例8: StringBufferInputStream
/**
* Construct a new {@code StringBufferInputStream} with {@code str} as
* source. The size of the stream is set to the {@code length()} of the
* string.
*
* @param str
* the source string for this stream.
* @throws NullPointerException
* if {@code str} is {@code null}.
*/
public StringBufferInputStream(String str)
{
if (str == null) {
throw new java.lang.NullPointerException ();
}
buffer = str;
count = str.length ();
}
示例9: SyncNotification
public SyncNotification(String strUrl, String strParams, boolean bRemoveAfterFire)
{
if ( strUrl.length() > 0 )
m_strUrl = RHODESAPP().canonicalizeRhoUrl(strUrl);
m_strParams = strParams;
m_bRemoveAfterFire = bRemoveAfterFire;
}
示例10: TransformerException
/**
* Wrap an existing exception in a TransformerException.
*
* <p>This is used for throwing processor exceptions before
* the processing has started.</p>
*
* @param message The error or warning message, or null to
* use the message from the embedded exception.
* @param e Any exception
*/
public TransformerException(String message, java.lang.Throwable e)
: base(((message == null) || (message.length() == 0))
? e.toString()
: message)
{
this.containedException = e;
this.locator = null;
}
示例11: getString
public String getString(String szName, String szDefValue)
{
Object value = findHashParam(szName);
String strRes = value != null ? value.ToString() : "";
if (strRes.length() == 0 && szDefValue != null && szDefValue.length() > 0)
strRes = szDefValue;
return strRes;
}
示例12: Invitation
/**
* Creates a new invitation.
*
* @param invitee the XMPP address of the invitee. The room will forward the invitation to this
* address.
* @param reason the reason why the invitation is being sent.
*/
public Invitation(String invitee, String reason) {
super();
Element element = addChildElement("x", "http://jabber.org/protocol/muc#user");
Element invite = element.addElement("invite");
invite.addAttribute("to", invitee);
if (reason != null && reason.length() > 0) {
invite.addElement("reason").setText(reason);
}
}
示例13: getServerQueryBody
public String getServerQueryBody(String strSrcName, String strClientID, int nPageSize)
{
String strQuery = "?client_id=" + strClientID +
"&p_size=" + nPageSize + "&version=3";
if (strSrcName.length() > 0)
strQuery += "&source_name=" + strSrcName;
return strQuery;
}
示例14: getServerQueryUrl
public String getServerQueryUrl(String strAction)
{
String strUrl = RhoConf.getInstance().getPath("syncserver");
if (strAction.length() > 0)
strUrl = CFilePath.join(strUrl, strAction);
else
strUrl = strUrl.substring(0, strUrl.length() - 1);
return strUrl;
}
示例15: ZipEntry
/**
* Constructs a new {@code ZipEntry} with the specified name.
*
* @param name
* the name of the ZIP entry.
* @throws IllegalArgumentException
* if the name length is outside the range (> 0xFFFF).
*/
public ZipEntry(String name)
{
if (name == null) {
throw new java.lang.NullPointerException();
}
if (name.length() > 0xFFFF) {
throw new java.lang.IllegalArgumentException();
}
this.name = name;
}