---
title: "How to get ascii values of chars in c#?"  
description: "How to get ascii values of chars in c#?"  
author: "Anonymous User"  
published: 2014-10-05  
updated: 2014-10-05  
canonical: https://www.mindstick.com/forum/2306/how-to-get-ascii-values-of-chars-in-c-sharp  
category: "c#"  
tags: ["c#", "asp.net"]  
reading_time: 1 minute  

---

# How to get ascii values of chars in c#?

I am accustom to [coding](https://www.mindstick.com/articles/12290/teaching-coding-from-the-metal-up-or-from-the-glass-back) in [java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming), but recently i have been making some [asp](https://www.mindstick.com/articles/751/introduction-to-asp-dot-net-mvc) webpages that use c#. in Java chars are [default](https://www.mindstick.com/interview/12771/what-is-the-importance-of-default-resources) represented by their numeric [ascii value](https://www.mindstick.com/interview/33822/how-to-find-the-ascii-value-of-any-character-in-sql-server) unless you [put](https://answers.mindstick.com/qa/111890/can-you-explain-the-difference-between-put-and-post-http-methods) them with a string. I have been unable to [repeat](https://www.mindstick.com/forum/156775/give-an-example-of-the-linq-repeat-method) this in c#. what do i need to do to get ascii [values](https://www.mindstick.com/forum/327/sum-textbox-values) of chars in c#.

\

## Replies

### Reply by Anonymous User

try this code:

```
public static IEnumerable<int> Utf32CodePoints(string s, int index){    for (int length = s.Length; index < length; index++)    {        yield return char.ConvertToUtf32(s, index);        if (char.IsSurrogatePair(s, index))               index++;        }    }}
```


---

Original Source: https://www.mindstick.com/forum/2306/how-to-get-ascii-values-of-chars-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
