typeof() : Get Type Name
On this page
Summary
Get the type name of a value. Useful for debugging and conditional logic.
Signature
typeof(value)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value |
Any | Yes | The value to get the type of |
Returns
Type: String
The .NET type name of the value.
Common Type Names
| Type | Result |
|---|---|
| String | "System.String" |
| Int32 | "System.Int32" |
| Int64 | "System.Int64" |
| Double | "System.Double" |
| Decimal | "System.Decimal" |
| Boolean | "System.Boolean" |
| DateTime | "System.DateTime" |
| Array | "System.Object[]" or specific array type |
| Null | "System.Object" or null |
Examples
Debug Output
Data:
doc.Params["model"] = new {
value = 42
};
Log Output:
Value type: System.Int32
Type-Based Conditional
Debugging Collection Types
Type Inspection for Troubleshooting
Data:
doc.Params["model"] = new {
user = "John Doe",
count = 42,
price = 19.99m,
isActive = true
};
Output:
<div class="debug-info">
<h3>Type Information</h3>
<ul>
<li>model: <>f__AnonymousType0</li>
<li>model.user: System.String</li>
<li>model.count: System.Int32</li>
<li>model.price: System.Decimal</li>
<li>model.isActive: System.Boolean</li>
</ul>
</div>
Notes
- Returns full .NET type name
- Useful for debugging data binding issues
- Can be used in conditional logic
- Anonymous types show generated names
- For null values, behavior may vary
- Primarily a debugging tool
- Use with `` helper for tracing