我如何在C#中的数组中进行一些计算 [英] How I Can Make Some Calculation In Array In C#

查看:401
本文介绍了我如何在C#中的数组中进行一些计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我有textbox1和textbox 2

in textbox1:

1,Vab ,,, kV,0.014646,0.0,0.0 ,-2048,2047

2,Vbc ,,, kV,0.014646,0.0,0.0,-2048,2047



in textbox2:

3,208,697,-1021,321,30,17,-67,43,-7,0,0,0,0,0,0,0,0,0,1 ,0,0,0,0,0,0

4,312,726,-1014,283,31,19,-65,45,-5,0,0,0,0 ,0,0,0,0,0,1,0,0,0,0,0,0

5,416,755,-1005,247,31,21,-67, 42,-4,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0





我的问题是:

1-我如何将每个值放在变量中,如数组(textbox1和textbox2中的值)

2 - 我如何在这个值(0.014646 * 321)中进行一些计算并将结果放入新数组?

如果我的问题不清楚,请告诉我解释更多

谢谢。

Hello
I have textbox1 and textbox 2
in textbox1 :
1,Vab,,,kV,0.014646,0.0,0.0,-2048,2047
2,Vbc,,,kV,0.014646,0.0,0.0,-2048,2047

in textbox2 :
3, 208, 697, -1021, 321, 30, 17, -67, 43, -7,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0
4, 312, 726, -1014, 283, 31, 19, -65, 45, -5,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0
5, 416, 755, -1005, 247, 31, 21, -67, 42, -4,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0


My questions is :
1- how i can put every value in variable like array ( value in textbox1 and textbox2 )
2- how i can make some calculation in this value ( 0.014646 * 321 ) and put the result in new array ?
please if my questions not clear tell me to explain more
thank you .

推荐答案

1日问题:

在这里你可以使用方法拆分和','作为分隔符。

Split为你提供一个字符串数组,其中包含来自源的所有元素。



第二个问题:

你必须解释目标是什么 - 你需要哪个输出?
For the 1st question :
Here you can use the Method Split with the ',' as delimiter.
Split delivers you a String-Array with all elements from the source seperated.

For the 2nd question :
You must explain what the goal shall be - which Output do you Need ?


以string.Split开头打破字符串,并使用int.TryParse转换所需的值;或使用CSV处理器读取字符串:快速CSV阅读器 [ ^ ]是一个很好的起始基地。 />


从那里,计算值非常简单 - 但你必须准确地计算出你想要做的事情:我们不能给你明确的通用问题说明。

我建议你先看一下List< T>但是,用于汇总输出结果的类。
Start with either string.Split to break the strings, and use int.TryParse to convert the values you need; or use a CSV processor to read the strings: A Fast CSV Reader[^] is a good starting base.

From that, it's pretty simple to calculate values - but you would have to work out exactly what you want to do: we can't give you explicit instructions for generic questions.
I'd suggest you start by looking at the List<T> class to assemble your output results, though.


这篇关于我如何在C#中的数组中进行一些计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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