如何在c#中将数据字符串转换为char [英] how to convert data string to char in c#

查看:294
本文介绍了如何在c#中将数据字符串转换为char的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于对象检测的项目

i想问...

如何将数据字符串转换为char

i have a project on object detection
i want to ask...
how to convert data string to char

label1.Text = string.Format("Number of Circle :{0}", circleCount);
label4.Text = string.Format("Number of Rectangular :{0}", rectangularCount);
label8.Text = string.Format("Number of Rhombus :{0}", rhombusCount);



如果label1值1然后我想转换为char a

如果label4值1然后我想转换为char b

如果label8值1然后我想转换为char c



怎么样?

对不起我新手,坏英语


if the label1 worth 1 then i want to convert to char a
if the label4 worth 1 then i want to convert to char b
if the label8 worth 1 then i want to convert to char c

how?
sorry im newbie, and bad english

推荐答案

如果你的意思是你想转换你的 circleCount rectangleCount rhombusCount 到字符,那很简单:



If you mean you want to convert the value of your circleCount, rectangularCount,and rhombusCount to characters, then that's pretty simple:

char c1 = (char) 'a' + circleCount;
char c2 = (char) 'b' + rectangularCount;
char c3 = (char) 'c' + rhombusCount;





如果不是你的意思是,你需要更详细地解释一下!



If that isn't what you mean, you need to explain in much better detail!


好的感谢解决方案...

我的项目是基于对象形状的对象检测与操纵器机器人...

关于我的问题我想用socket udp将数据从c#发送到vb6(c#是客户端,vb6是服务器)。

如果检测到圆圈,则圈数:{1}然后我想发送圈子:1 = A到vb6,因为在vb6中我接受带有char的数据。

因此我需要将字符串转换为字符串...

谢谢,,,

抱歉我的英文不好
Ok thanks for solution...
my project is object detection base on object shape with manipulator robot...
about my question i want to send data from c# to vb6 with socket udp(c# is client and vb6 is server).
if circle detected then Number of Circle :{1}" then i want to send circle :1 = A to vb6, because in vb6 i accept data with char.
Therefore i need convert string to char...
Thanks ,,,
sorry for my bad english


这篇关于如何在c#中将数据字符串转换为char的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆