---
title: "How can I get the ASCII code for a character in C#?"  
description: "How can I get the ASCII code for a character in C#?"  
author: "Anonymous User"  
published: 2011-01-06  
updated: 2020-09-22  
canonical: https://www.mindstick.com/interview/314/how-can-i-get-the-ascii-code-for-a-character-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How can I get the ASCII code for a character in C#?

Casting the char to an int will give you the ASCII value: char c = 'f';

System.Console.WriteLine((int)c);

## Answers

### Answer by Anonymous User

Casting the char to an int will give you the ASCII value: char c = 'f';

System.Console.WriteLine((int)c);


---

Original Source: https://www.mindstick.com/interview/314/how-can-i-get-the-ascii-code-for-a-character-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
