Edit

Share via


CodePrimitiveExpression Class

Definition

Represents a primitive data type value.

C#
public class CodePrimitiveExpression : System.CodeDom.CodeExpression
C#
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodePrimitiveExpression : System.CodeDom.CodeExpression
Inheritance
CodePrimitiveExpression
Attributes

Examples

The following example demonstrates use of CodePrimitiveExpression to represent values of several primitive types.

C#
// Represents a string.
CodePrimitiveExpression stringPrimitive = new CodePrimitiveExpression("Test String");
// Represents an integer.
CodePrimitiveExpression intPrimitive = new CodePrimitiveExpression(10);
// Represents a floating point number.
CodePrimitiveExpression floatPrimitive = new CodePrimitiveExpression(1.03189);
// Represents a null value expression.
CodePrimitiveExpression nullPrimitive = new CodePrimitiveExpression(null);

Remarks

CodePrimitiveExpression can be used to represent an expression that indicates a primitive data type value.

The Value property specifies the primitive data type value to represent.

Primitive data types that can be represented using CodePrimitiveExpression include null; string; 16-, 32-, and 64-bit signed integers; and single-precision and double-precision floating-point numbers.

Constructors

CodePrimitiveExpression()

Initializes a new instance of the CodePrimitiveExpression class.

CodePrimitiveExpression(Object)

Initializes a new instance of the CodePrimitiveExpression class using the specified object.

Properties

UserData

Gets the user-definable data for the current object.

(Inherited from CodeObject)
Value

Gets or sets the primitive data type to represent.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9