GameDesign 板


LINE

namespace Console_Wars { class Hero (第一个class) { . . public void showLower2 () {..} . . string lower_2; <- in class Hero } public void showLower1 () {..} string lower_1; <- global //console程式 class Program (第二个class) { . . static void Main(string[] args) { . . string lower = HeroA.name.ToLower(); HeroA.showLower2(); (主要问题点) showLower1 (); . . } <- local var lower 消灭 } 1.Hero::showLower2是宣告於class Hero中,只看的到class自己的Hero::lower_2 2.Console_Wars::showLower1也只能秀Console_Wars::lower_1 <- global 至於你在Main里面宣告的local var lower,1跟2都看不到 namespace Console_Wars { class Heros () { public void showlower () { Console.WriteLine (name.ToLower ()); } } public void showlower (string Name) <-将name当成function变数带进来 { Console.WriteLine = (Name.ToLower()); } . . static void Main(string[] args) { . . showlower (HeroA.name) <-呼叫function,并且把变数带进去 HeroA.showlower () <-直接使用class的func . . } } ___ 因为我没玩过C#,不知道概念跟C会不会有太大出入,有错请指正 问题应该在,你还没有 变数范围的概念? (variable scope) 不过function概念的话,可以直接丢值进来就解决了,没有必要坚持用已有var 或是直接在class里面做完 Heros::showlower,直接当成class 的东西使用 -- 明知道这是不可能的愿望 却如同烙印的爪痕沁入大地 假如 可以实现的话 将我的存在剥夺 舍弃也无妨 祈祷着 祈求着 幻想也好 --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 60.251.182.68
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/GameDesign/M.1487040599.A.0E6.html ※ 编辑: LayerZ (60.251.182.68), 02/14/2017 10:59:59
1F:推 anterior: 非常感谢您的指导 02/14 11:00
2F:→ anterior: 最後面您说的对,由於我刚开始学 02/14 11:01
3F:→ anterior: 因此会想要将学过的或是还没有学过的 02/14 11:02
4F:→ anterior: 自己尝试排列组合,可以顺便厘清结构 02/14 11:02
5F:→ anterior: 而且在Visual自带的报错部分也学习到蛮多的 02/14 11:03
6F:→ anterior: 不过目前遇到比较多的问题是 02/14 11:05
7F:→ anterior: 我学会的function还不多 02/14 11:05
8F:→ anterior: 因此时常遇到不知是结构的问题 02/14 11:06
9F:→ anterior: 抑或者是这个function无法这样使用 02/14 11:06
10F:→ anterior: 因此我现在会先在学习更多的function後 02/14 11:06
11F:→ anterior: 再来慢慢自己研究尝试 02/14 11:07
12F:→ anterior: 非常感谢各位的指导^_^ 02/14 11:07
13F:→ LayerZ: ...怎麽看完有点担心阿XDD 02/14 11:08
14F:→ LayerZ: function就是function,懂概念的话,什麽函式都一样阿XD 02/14 11:09
15F:→ LayerZ: 不过就多try吧=w= 02/14 11:10
16F:推 anterior: 噗... 我会时常来向版上的前辈们来报告进度的 02/14 11:10
17F:推 supertyphoon: 企划基本上就是各领域都要有像LayerZ这样的分析能力 02/15 13:00
18F:推 supertyphoon: 各领域就算没比该专业强 如果能撑到该领域闭嘴就行 02/15 13:03







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BuyTogether站内搜寻

TOP