本文整理汇总了C#中ITypeSymbol.IsPointerType方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeSymbol.IsPointerType方法的具体用法?C# ITypeSymbol.IsPointerType怎么用?C# ITypeSymbol.IsPointerType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeSymbol
的用法示例。
在下文中一共展示了ITypeSymbol.IsPointerType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDefaultExpression
public override SyntaxNode CreateDefaultExpression(ITypeSymbol type)
{
// If it's just a reference type, then "null" is the default expression for it. Note:
// this counts for actual reference type, or a type parameter with a 'class' constraint.
// Also, if it's a nullable type, then we can use "null".
if (type.IsReferenceType ||
type.IsPointerType() ||
type.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T)
{
return SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression);
}
switch (type.SpecialType)
{
case SpecialType.System_Boolean:
return SyntaxFactory.LiteralExpression(SyntaxKind.FalseLiteralExpression);
case SpecialType.System_SByte:
case SpecialType.System_Byte:
case SpecialType.System_Int16:
case SpecialType.System_UInt16:
case SpecialType.System_Int32:
case SpecialType.System_UInt32:
case SpecialType.System_Int64:
case SpecialType.System_UInt64:
case SpecialType.System_Decimal:
case SpecialType.System_Single:
case SpecialType.System_Double:
return SyntaxFactory.LiteralExpression(
SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal("0", 0));
}
// Default to a "default(<typename>)" expression.
return SyntaxFactory.DefaultExpression(type.GenerateTypeSyntax());
}