本文整理汇总了C#中java.lang.String.trim方法的典型用法代码示例。如果您正苦于以下问题:C# String.trim方法的具体用法?C# String.trim怎么用?C# String.trim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.String
的用法示例。
在下文中一共展示了String.trim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getType
private TypeInfo getType(String name) {
name = name.trim();
int dimensions = 0;
while (name.endsWith("[]")) {
dimensions++;
name = name.substring(0, name.length() - 2);
}
TypeInfo result;
switch (name) {
case "boolean":
result = context.TypeSystem.BooleanType;
break;
case "byte":
result = context.TypeSystem.ByteType;
break;
case "char":
result = context.TypeSystem.CharType;
break;
case "short":
result = context.TypeSystem.ShortType;
break;
case "int":
result = context.TypeSystem.IntType;
break;
case "long":
result = context.TypeSystem.LongType;
break;
case "float":
result = context.TypeSystem.FloatType;
break;
case "double":
result = context.TypeSystem.DoubleType;
break;
default:
int idx = name.indexOf(".");
String prefix;
if (idx == -1) {
prefix = name;
name = null;
} else {
prefix = name.substring(0, idx);
name = name.substring(idx + 1);
}
var members = context.MemberResolver.resolveName(context.CurrentType, prefix, Query.empty<TypeInfo>()).toList();
if (!members.any()) {
if (name == null) {
return null;
}
var packageName = context.MemberResolver.getPackageFromAlias(prefix);
if (packageName == null) {
if (context.MemberResolver.TypeFinder.getSubPackages(prefix).any()
|| context.MemberResolver.TypeFinder.getClasses(prefix).any()) {
packageName = prefix;
} else {
return null;
}
}
var found = false;
do {
idx = name.indexOf('.');
if (idx == -1) {
prefix = name;
name = null;
} else {
prefix = name.substring(0, idx);
name = name.substring(idx + 1);
}
foreach (var s in context.MemberResolver.TypeFinder.getSubPackages(packageName)) {
if (s.equals(prefix)) {
packageName = packageName + '/' + prefix;
found = true;
break;
}
}
if (!found && !context.MemberResolver.TypeFinder.getClasses(packageName).contains(prefix)) {
return null;
}
} while (name != null && found);
result = context.TypeSystem.getType(packageName + '/' + prefix);
} else if (members.count() > 1) {
return null;
} else {
result = members.first().Type;
}
break;
}
while (dimensions-- > 0) {
type = type.ArrayType;
}
return result;
}