---
title: "cannot convert int to string"  
description: "cannot convert int to string"  
author: "Anonymous User"  
published: 2014-09-05  
updated: 2014-09-05  
canonical: https://www.mindstick.com/forum/2253/cannot-convert-int-to-string  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# cannot convert int to string

```
var query = from s in student            select new ListItem            {                ID = s.studentId,                Name = s.studentName            };
```

When I tried to [execute](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) I got the [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing)

[Cannot implicitly](https://www.mindstick.com/forum/34469/cannot-implicitly-convert-type-long-to-long) [convert](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) type '[int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql)' (studentId) to '[string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp)' (ID).

Is there anyway I can achieve this?

## Replies

### Reply by Sumit Kesarwani

Hi Jeet,\
try this:

```
var query = from s in student                       
select new ListItem                       
{                           
ID = Convert.ToString(s.studentId),                           
Name = s.studentName                        };
```


---

Original Source: https://www.mindstick.com/forum/2253/cannot-convert-int-to-string

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
