本文整理汇总了C#中java.lang.String类的典型用法代码示例。如果您正苦于以下问题:C# String类的具体用法?C# String怎么用?C# String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
String类属于java.lang命名空间,在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getDirectoryName
public static String getDirectoryName(String path) {
if (path != null) {
int index = path.lastIndexOf(DIRECTORY_SEPARATOR_CHAR);
int index2 = path.lastIndexOf(ALT_DIRECTORY_SEPARATOR_CHAR);
if (index2 > index) {
index = index2;
}
if (index != -1) {
if (index == path.length() - 1) {
if (path.indexOf(VOLUME_SEPARATOR_CHAR) == index - 1) {
return null;
} else {
path = path.substring(0, index);
}
} else {
if (path.indexOf(VOLUME_SEPARATOR_CHAR) == index - 1) {
path = path.substring(0, index + 1);
} else {
path = path.substring(0, index);
}
}
if (path.length() == 2 && path[1] == VOLUME_SEPARATOR_CHAR) {
return "";
}
}
return path;
}
return null;
}
示例2: LocalInfo
LocalInfo(TypeInfo type, String name, int index, Label beginLabel, Label endLabel) {
this.type = type;
this.name = name;
this.index = index;
this.beginLabel = beginLabel;
this.endLabel = endLabel;
}
示例3: main
public static void main(String[] args) {
System.out.println();
System.out.println();
var result = new Application().run(args);
System.out.println("Done("+result+")");
System.exit(result);
}
示例4: buildPackageDocumentation
void buildPackageDocumentation(String packageName, PackageDeclarationNode packageDeclaration) {
var comment = ParserHelper.decodeDocumentation(context.Text, packageDeclaration.DocumentationOffset,
packageDeclaration.DocumentationLength);
memberKind = null;
node = packageDeclaration;
appendDocumentation("N:" + packageName, comment);
}
示例5: addLeadingDigitsPattern
public NumberFormat addLeadingDigitsPattern(String value)
{
if (value == null) {
throw new NullPointerException();
}
leadingDigitsPattern_.add(value);
return this;
}
示例6: writeFloat
/*
public void writeFloat(float v) {
writeInt(Float.floatToIntBits(v));
}
public void writeDouble(double v) {
writeLong(Double.doubleToLongBits(v));
}
*/
public void writeBytes(String s)
{
int len = s.length();
for (int i = 0 ; i < len ; i++) {
@out.write((byte)s.charAt(i));
}
incCount(len);
}
示例7: CodeError
public CodeError(String filename, int id, int level, String message, int line, int column) {
this.Filename = filename;
this.Id = id;
this.Level = level;
this.Message = message;
this.Line = line;
this.Column = column;
}
示例8: getMessage
public String getMessage(Locale locale, String key, params Object[] args) {
var rb = getResourceBundle(locale);
if (rb != null) {
try {
return MessageFormat.format(rb.getString(key), args);
} catch {
}
}
return key;
}
示例9: hasNature
public static bool hasNature(IProject project, String natureId) {
if (project.exists() && project.isOpen()) {
try {
return project.hasNature(natureId);
} catch (CoreException e) {
Environment.logException(e);
}
}
return false;
}
示例10: super
: super(typeSystem, name) {
this.typeSystem = typeSystem;
this.descriptor = "L" + name + ";";
numericTypeKind = TypeKinds[name];
if (numericTypeKind == null) {
numericTypeKind = NumericTypeKind.None;
}
new ClassReader(bytes).accept(new OutlineVisitor(this), ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
this.genericsScope = new Scope<String, TypeInfo>();
this.genericsScope.enterScope();
}
示例11: PhoneNumberMatch
/**
* Creates a new match.
*
* @param start the start index into the target text
* @param rawString the matched substring of the target text
* @param number the matched phone number
*/
internal PhoneNumberMatch(int start, String rawString, PhoneNumber number)
{
if (start < 0) {
throw new IllegalArgumentException("Start index must be >= 0.");
}
if (rawString == null || number == null) {
throw new NullPointerException();
}
this._start = start;
this._rawString = rawString;
this._number = number;
}
示例12: getInfo
public static MemberInfo getInfo(MethodInfo getAccessor, MethodInfo setAccessor, String name) {
var result = (getAccessor ?? setAccessor).getUserData(typeof(PropertyMemberInfo));
if (result == null) {
result = new PropertyMemberInfo(getAccessor, setAccessor, name);
if (getAccessor != null) {
getAccessor.addUserData(result);
}
if (setAccessor != null) {
setAccessor.addUserData(result);
}
}
return result;
}
示例13: getFileName
public static String getFileName(String path) {
if (path != null) {
int index = path.lastIndexOf(DIRECTORY_SEPARATOR_CHAR);
if (index == -1) {
index = path.lastIndexOf(ALT_DIRECTORY_SEPARATOR_CHAR);
}
if (index == -1) {
return path;
}
return path.substring(index + 1);
}
return null;
}
示例14: addTypeToTypeRelation
public void addTypeToTypeRelation(String referencingType, String referencedType) {
var referencing = referencingTypes.get(referencedType);
if (referencing == null) {
referencing = new HashSet<String>();
referencingTypes[referencedType] = referencing;
}
referencing.add(referencingType);
var referenced = referencedTypes.get(referencingType);
if (referenced == null) {
referenced = new HashSet<String>();
referencedTypes[referencingType] = referenced;
}
referenced.add(referencedType);
}
示例15: addFileToTypeRelation
public void addFileToTypeRelation(String fileName, String typeName) {
var contents = fileContents.get(fileName);
if (contents == null) {
contents = new HashSet<String>();
fileContents[fileName] = contents;
}
contents.add(typeName);
var locations = typeLocations.get(typeName);
if (locations == null) {
locations = new HashSet<String>();
typeLocations[typeName] = locations;
}
locations.add(fileName);
}