using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Collections;
using System.IO;
namespace kongzhitai
{
class Program
{
public static void Main() //主程序部分,用来计算最终温度temperature;
{
double rou ; //定义密度;
double bire = 630; //定义比热;
double lamda1 = 34; //定义x方向导热系数;
double lamda2 = 38; //定义y方向导热系数;
double temperature;
rou = GetRou(); //rou的值从方法中返回;
temperature= lamda1*rou + lamda2 * bire;
Console.WriteLine("{0}", temperature);
}
public double GetRou(); //此方法用来计算rou,并将rou的值返回,以便主程序调用; {
getValue xishu = new getValue(); // xishu是从另一个类getValue中得到的;
double a=0;
double b=0;
a = xishu.math(); //此方法用来计算rou,并将rou的值返回,以便主程序调用;
b = xishu.math();
result = a + b* 125;
return result;
}
}
class getValue //此类用来读取指定文本文档的字符串,并将字符串分割,转化为double型;
{ //因为字符串被分割为多个数据,存到数组里,所以此类要返回多个值;
public double[] math()
{
double[] dblValues;
string line = "";
StreamReader sr = new StreamReader(@"E:\1.txt", System.Text.Encoding.GetEncoding("gb2312"));
while ((sr.EndOfStream != true))
{
line = sr.ReadLine();
string[] arr = line.Split(' ');
dblValues = new double[arr.Length];
for (int i = 0; i < arr.Length; i++)
{
if (double.TryParse(arr[i], out dblValues[i]))
{
Console.WriteLine("{0}", dblValues[i]);
}
}
}
return dblValues;
}
}
}
辛苦大家!这个程序主要是先读取文本文档的值,分割转化为double型,因为是多个值,所以存到数组里了。我想问的是其他程序调用时怎样区分我存到数组里的值,恳请大家帮我把程序调通,我很笨,做不来。谢谢大家!
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Collections;
using System.IO;
namespace kongzhitai
{
class Program
{
public static void Main() //主程序部分,用来计算最终温度temperature;
{
double rou ; //定义密度;
double bire = 630; //定义比热;
double lamda1 = 34; //定义x方向导热系数;
double lamda2 = 38; //定义y方向导热系数;
double temperature;
rou = GetRou(); //rou的值从方法中返回;
temperature= lamda1*rou + lamda2 * bire;
Console.WriteLine("{0}", temperature);
}
public double GetRou(); //此方法用来计算rou,并将rou的值返回,以便主程序调用; {
getValue xishu = new getValue(); // xishu是从另一个类getValue中得到的;
double a=0;
double b=0;
a = xishu.math(); //此方法用来计算rou,并将rou的值返回,以便主程序调用;
b = xishu.math();
result = a + b* 125;
return result;
}
}
class getValue //此类用来读取指定文本文档的字符串,并将字符串分割,转化为double型;
{ //因为字符串被分割为多个数据,存到数组里,所以此类要返回多个值;
public double[] math()
{
double[] dblValues;
string line = "";
StreamReader sr = new StreamReader(@"E:\1.txt", System.Text.Encoding.GetEncoding("gb2312"));
while ((sr.EndOfStream != true))
{
line = sr.ReadLine();
string[] arr = line.Split(' ');
dblValues = new double[arr.Length];
for (int i = 0; i < arr.Length; i++)
{
if (double.TryParse(arr[i], out dblValues[i]))
{
Console.WriteLine("{0}", dblValues[i]);
}
}
}
return dblValues;
}
}
}
辛苦大家!这个程序主要是先读取文本文档的值,分割转化为double型,因为是多个值,所以存到数组里了。我想问的是其他程序调用时怎样区分我存到数组里的值,恳请大家帮我把程序调通,我很笨,做不来。谢谢大家!
解决方案 »
- 请问有谁有指针表那样的控件
- 在VS2005中如何用鼠标绘图
- 各位高手我太菜了,菜鸟求救!!!
- 【小猪猪】如何自动调用WebBrowser控件里DOC的 <a>标签的点击事件?
- C#如何设置让过程等待几秒钟?
- 关于在winform中如何操作word 从列表中打开选定的word,修改后,再保存到服务器上
- 初學者的問題 各位大哥幫忙解決一下
- javascript 菜鸟提问,关于IFrame的如何控制父页面/frame的src问题.
- 请问一个自己编写DELETECOMMAND的问题?
- 请问http和https的区别
- winform的datagridview问题,每一行都有一个checkbox,我想根据选中的checkbox对下面部分数据进行处理,但是发现每选一次checkbox的value不一定选中的是true
- C#连接数据库问题
{
}
out 的部分就是返回值,想返回几个就几个
回来一个数组么?
在下如果是需要多return结果都是这样处理
然后再通过其他方法处理结果
class Results
{
public int errorCode; public string errorMsg;
} private Results GetLotsOfResults()
{
Results res = new Results(); res.errorCode = 1;
res.errorMsg = "error!"; return res;
} private void GetLotsOfResults(string inParam, ref int errorCode, ref string errorMsg)
{
errorCode = 1;
errorMsg = "Error!!";
}
void foo()
{
Results ret = GetLotsOfResults();
//使用ret//一种方法
string errorMsg = string.Empty;
int errorCode = 0; GetLotsOfResults("This is what you need to passed in", ref errorCode, ref errorMsg); }