首页 新闻 会员 周边

这是一道简单的装箱拆箱操作,求解答哪里出错了

0
[已解决问题] 解决于 2013-10-15 16:07
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace 拆箱操作
 7 {
 8     class Program
 9     {
10         static void Main(string[] args)
11         {
12             string s = SimulationWriteLine("笔记本的重量为:{0}kg", 1.6);
13             //调用SimulationWriteLine方法
14             Console.WriteLine(s);
15             //输出到控制台
16         }
17 
18         public static string SimulationWriteLine(string format, object arg0);
19     
20         {
21         //将任意值类型转换为string类型
22             string arg =Convert .ToString  (arg0);
23         //使用replace()方法,将字符串中子字符串替换为新的字符串
24             string s = format.replace("{0}",arg);
25             return s;
26         }
27     }
28 }
c#
I love 小丽子的主页 I love 小丽子 | 菜鸟二级 | 园豆:206
提问于:2013-10-15 15:29
< >
分享
最佳答案
0

public static string SimulationWriteLine(string format, object arg0); 请问这里 加分号什么个意思??

public static string SimulationWriteLine(string format, object arg0)
        {
            //将任意值类型转换为string类型
            string arg = Convert.ToString(arg0);
            //使用replace()方法,将字符串中子字符串替换为新的字符串
            string s = format.Replace("{0}", arg);//请注意大小写 replace
            return s;
        }

奖励园豆:5
wolfy | 老鸟四级 |园豆:2636 | 2013-10-15 15:39
其他回答(1)
0

楼主难道是用记事本写代码?

 

gw2010 | 园豆:1487 (小虾三级) | 2013-10-15 16:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册