Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
楼主: qwqwqwqw
打印 上一主题 下一主题

关于电脑课程的问题

[复制链接]

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

21#
发表于 2010-10-16 05:20 PM |只看该作者
谢谢各位大大
我下载了 visual studio 2008
我还上youtube看了一些教程
请问大部分的program就可以用 v ...
qwqwqwqw 发表于 2010-10-16 05:06 PM


eh 。。。 不可以那么说。
如果人家要用 Window 以外的 OS 你就还是要啃书学其他的语言。

就好比 UNIX, Linux, Ubuntu, Red Hat, 你还觉得 你写的 EXE 能搬去哪里用吗??


回复

使用道具 举报

57

主题

1

好友

3274

积分

本站名嘴

Rank: 11Rank: 11

22#
发表于 2010-10-16 05:50 PM |只看该作者
You should first open a DOS command shell. (If you don't know what it is, clic on the Start menu then run (at the bottom) and type, in the text field: "cmd".
exercise: there is an easiest way to do that, try to find it.)
You should begin to work in an empty directory for this. let call it "C:\learncs". Type in the shell:

> md C:\learncs
> cd C:\learncs
> C:

Now you should create your first C# program, type "notepad hello.cs" and type (in the notepad)

using System;

public class Hello
{
public static void Main()
{
Console.WriteLine("Hello C# World  ");
}
}
the using keyword just let you write Console at line 7, instead of System.Console. It's very usefull shortcut when you use a lot of "class" define in System.
Save the file.
Now you could compile. Type in the DOS Shell again and type:
  csc /nologo /out:hello.exe hello.cs
You probaly have some errors, correct them, compile again, and now you have a working hello.exe program… type hello, see…
我刚完成了这个
可是要怎样才知道我成功了呢?
在 notepad 打了之后 储存区desktop然后再 cmd type     hello.cs?


回复

使用道具 举报

57

主题

1

好友

3274

积分

本站名嘴

Rank: 11Rank: 11

23#
发表于 2010-10-16 05:53 PM |只看该作者
还有 compile是什么? 要怎样弄
当我打这个的时候 csc /nologo /out:hello.exe hello.cs
他会出现 'csc' is not recognized as an internal or external command,
这是什么问题
我的windows 是 windows 7 home premium 64bit


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

24#
发表于 2010-10-16 06:53 PM |只看该作者
还有 compile是什么? 要怎样弄
当我打这个的时候 csc /nologo /out:hello.exe hello.cs
他会出现 'csc' i ...
qwqwqwqw 发表于 2010-10-16 05:53 PM


请问你安装 Visual Studio\ Visual C# 了吗?
我不知道Window是不是会自带Compiler, 但是你还是安装吧。

有个秘诀。
Window 7 下, 你可以 Search 出来。
首先, 你Click 着 C:\Program Files\Microsoft Visual Studio x.x
但是不要按进去。

(x = 你的版本)

然后你 Search "vcvars"

我使用vcvars32.bat, 因为我的 os Window 7 是 32 bit。

打开个文件夹, 叫做 hello, 或你喜欢。
把 hello.cs 和 vcvars32.bat 放进hello 文件夹。

因为没人会那么勤劳去背 哪个 bat file 的 location 的。
所以可以的话就放去一个你比较容易见到的地方好了。

然后打开 Command Prompt。
(Window 7\ Vista 可以在 Start Menu 打 CMD,  XP 的话请用 RUN。)

键入 cd C:\Users\ASUS\Desktop\hello                                 
我的hello folder 放在 Desktop, 所以我 cd 过去哪个 location。

键入 vcvars32.bat
先让这个 bat 跑先。

键入 csc hello.cs

然后你看到你的 folder 内会多出个 hello.exe 的话, 那么你就成功了。


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

25#
发表于 2010-10-16 06:55 PM |只看该作者
本帖最后由 宅男-兜着走 于 2010-10-16 06:57 PM 编辑
还有 compile是什么? 要怎样弄
当我打这个的时候 csc /nologo /out:hello.exe hello.cs
他会出现 'csc' i ...
qwqwqwqw 发表于 2010-10-16 05:53 PM


Compiler 就是篇译 器, 把你的 .cs, .vb 等等的Code, 转变成一个 .exe (Executable file)

那么你就能 double click 来使用。


你现在看的教程是 手动 Compile, 不过相信我,你写深入的时候就没必要了。
Visual Studio 可以轻易的帮你 Compile。


回复

使用道具 举报

57

主题

1

好友

3274

积分

本站名嘴

Rank: 11Rank: 11

26#
发表于 2010-10-16 07:10 PM |只看该作者
ok...
我用2008的时候有时会有error出来
所以我现在下载2010的   
晚点会弄一弄 (今晚半夜吧)
有问题的话我会在这边回复的


回复

使用道具 举报

57

主题

1

好友

3274

积分

本站名嘴

Rank: 11Rank: 11

27#
发表于 2010-10-18 10:13 PM |只看该作者
Now you become to be pretty confident, I guess, so we could start using multiple file, and even a dll ? go into an other directory (or stay in this one, I won't mind) and create 2 file:

hello.cs

using System;

public class Hello
{
public static void Main()
{
HelloUtil.Echo h = new HelloUtil.Echo("Hello my 1st C# object !");
h.Tell();
}
}
echo.cs

using System;

namespace HelloUtil
{
public class Echo
{
string myString;

public Echo(string aString)
{
myString = aString;
}

public void Tell()
{
Console.WriteLine(myString);
}
}
}
Note in hello.cs I have used the syntax "HelloUtil.Echo" it's because Echo is in the namespace HelloUtil, you could have typed (at he start of the file) using HelloUtil and avoid HelloUtil., that's the way namespace work.

Now you could compile both in one .exe with
  > csc /nologo /out:hello.exe *.cs
But it's not my intention, no.
Well.
(Have you tried?)
Let's go building a DLL:
  > csc /nologo /t:library /out:echo.dll echo.cs
that's it (dir will confirm).
Now we could use it …
  > csc /out:hello.exe /r:echo.dll hello.cs
if you typed "hello" it will worked as usual…, but if you delete "echo.dll" the program will now crash: it use the DLL. You could also change Echo.cs, rebuild the DLL and see… that's the advantage of DLL!

You could also put your DLL in the global assembly cache (GAC), and any program would be able to access it, even if the DLL is not in its directory!
to put it in the GAC, I sugest you read MS doc but here are the unexplained step:

create your assembly key, create it once and use it for every version. you create it with:
  sn -k myKeyName.snk
the .snk file should be in your compilation directory (the one where your run csc)
create a strong asssembly title by adding in any .cs source file the following directive at top level: using System.Reflection;       
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("My Lib Title")]
[assembly: AssemblyVersion("1.2.3.4")]
[assembly: AssemblyKeyFile("myKeyName.snk")]
now add it to the GAC:
  > gacutil.exe /if myLib.dll

By the way, did I tell you ? when I referenced the hello.dll while compiling, remember? csc /out:hello.exe /r:echo.dll hello.cs, it could have been any assembly, even a .exe !!!

这个要怎样做啊?
第3个tutorial就不会了 ( 英语不是很好 所以有点不明白)


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

28#
发表于 2010-10-18 10:51 PM |只看该作者
Now you become to be pretty confident, I guess, so we could start using multiple file, and even a dl ...
qwqwqwqw 发表于 2010-10-18 10:13 PM


他都说的很明白了? 你什么不会?


回复

使用道具 举报

57

主题

1

好友

3274

积分

本站名嘴

Rank: 11Rank: 11

29#
发表于 2010-10-18 11:06 PM |只看该作者
mutiple file 我会(我也成功弄到了)

You could also put your DLL in the global assembly cache (GAC), and any program would be able to access it, even if the DLL is not in its directory!
to put it in the GAC, I sugest you read MS doc but here are the unexplained step:

create your assembly key, create it once and use it for every version. you create it with:
  sn -k myKeyName.snk
the .snk file should be in your compilation directory (the one where your run csc)
create a strong asssembly title by adding in any .cs source file the following directive at top level: using System.Reflection;        
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("My Lib Title")]
[assembly: AssemblyVersion("1.2.3.4")]
[assembly: AssemblyKeyFile("myKeyName.snk")]
now add it to the GAC:
  > gacutil.exe /if myLib.dll

By the way, did I tell you ? when I referenced the hello.dll while compiling, remember? csc /out:hello.exe /r:echo.dll hello.cs, it could have been any assembly, even a .exe !!!
这边什么assembly key 我不明白 (弄不到)


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

30#
发表于 2010-10-19 01:51 AM |只看该作者
mutiple file 我会(我也成功弄到了)

You could also put your DLL in the global assembly cache (GAC), ...
qwqwqwqw 发表于 2010-10-18 11:06 PM


哈哈哈哈, sorry~ 这个我不会, 我没去 Test, 因为 Visual Studio 会自己生成的。


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-10-27 03:29 PM , Processed in 0.091823 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部