這個怎么給temp賦值呢,可以隨便賦值嗎例如string=temp?還有下面{0},{1}是什么鬼完全不會了。求給位大佬幫幫忙
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string today;//今天的午飯
? ? ? ? ? ? string tomorrow;//明天的午飯
? ? ? ? ? ? today = "魚香肉絲";
? ? ? ? ? ? tomorrow = "小雞燉蘑菇";
? ? ? ? ? ? //請在這里補(bǔ)充代碼,實現(xiàn)變量today和tomorrow的交換
? ? ? ? ? ??
? ? ? ? ? ??
? ? ? ? ? ??
? ? ? ? ? ??
? ? ? ? ? ??
? ? ? ? ? ??
? ? ? ? ? ??
? ? ? ? ? ? //打印
? ? ? ? ? ? Console.WriteLine("我今天吃{0},明天吃{1}。",today,tomorrow);
? ? ? ? }
? ? }
}
2019-07-26
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string today;//今天的午飯
? ? ? ? ? ? string tomorrow;//明天的午飯
? ? ? ? ? ? today = "魚香肉絲";
? ? ? ? ? ? tomorrow = "小雞燉蘑菇";
? ? ? ? ? ? Console.WriteLine("我今天吃{1},明天吃{0}。",today,tomorrow);
? ? ? ? }
? ? }
}
怎么辦我是不是懶到家了
2018-10-30
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
??????????? string today;//今天的午飯
??????????? string tomorrow;//明天的午飯
??????????? today = "魚香肉絲";
??????????? tomorrow = "小雞燉蘑菇";
??????????? //請在這里補(bǔ)充代碼,實現(xiàn)變量today和tomorrow的交換
??????????? string temp;
??????????? temp=today;
??????????? today=tomorrow;
??????????? tomorrow=temp;
??????????? //打印
??????????? Console.WriteLine("我今天吃{0},明天吃{1}。",today,tomorrow);
??????? }
??? }
}
你用這個調(diào)試運行試試看,你就知道你錯誤在哪里了,這個是我剛剛寫的正確的, 大括號里頭的0 1都表示是占位符,必須從0開始編排,0對應(yīng)的是today,1對應(yīng)的是tomorrow,today對應(yīng)的是魚香肉絲,tomorrow對應(yīng)的是小雞燉蘑菇,那么通過string temp,定義了一個空瓶子,然后將today與tomorrow進(jìn)行的一個交換就是你現(xiàn)在看到的答案了,這么寫你應(yīng)該能明白了吧!
2018-10-09
temp=today; today=tomorrow; tomorrow=temp;? 就好了。至于0 .1? 是指的變量的位置