如何添加方法和属性? [英] How do I add methods and properties?

查看:52
本文介绍了如何添加方法和属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


使用Microsoft Visual C#2005 Express Edition,我正在尝试创建一个

类库(.dll)来包含在一个Delphi项目中。


因为我刚刚建立.dll,我已经搜索了互联网,现在我已经按照一个例子来看了我的b $ b '
http:// www .dotnetheaven.com / Uploadfi ... 14101AM / pr12.a

spx,它解释了如何构建.dll以及如何调用它。到目前为止

很好。


但是当我来添加方法和属性时,我被问到了

右键单击类名并选择添加 - >添加方法(或类似的

属性),这在Express Edition中不可用!我已经再次检查了互联网,这确实在EE中没有。


然而,Express Edition是我唯一的版本,所以我会

我真的想知道如何自己添加这些方法和属性,

我认为*是*可能的(否则它会相当愚蠢到

包括创建类库的能力,imho)。


请问有人请向我解释我是如何做到的?或者指点一下

一个很好的教程的正确方向?


提前致谢!


Ikke

解决方案

2008年7月12日星期六15:10:07 -0700,Ikke< ik ** @ hier.bewrote:
< blockquote class =post_quotes>
[...]

然而,Express Edition是我唯一的版本,所以我会

真的很喜欢我知道如何自己添加这些方法和属性,

,我认为*是*可能的(否则它将是相当愚蠢的

包括创建类库的能力, imho)。


有人请你解释我是怎么做到的吗?或者指点一下

一个好教程的正确方向?



您只需手动输入即可。打开相应的.cs文件,其中

定义类并自行添加。


事实上,我很惊讶任何人都会使用GUI从头开始添加方法或

属性(与实现

接口所需的属性相反,覆盖现有方法等,IDE有足够的

保存一些实际打字的信息)。这样的功能增加了很少的价值,我甚至没有意识到它存在于VS. :)


Pete


Ikke写道:


使用Microsoft Visual C#2005 Express Edition,我正在尝试创建一个

类库(.dll)以包含在Delphi项目中。



你与Delphi的整合点是什么?使用Delphi for .NET?

(我在Delphi编译器上为CodeGear工作(现在是Embarcadero的一部分)。)


无论如何,编程是主要是基于文本的学科。我不会因为GUI /菜单/等而浪费时间。用于编写新代码。这是一个简单的C#

类库:


--- 8< ---

使用System;

公共类MyClass

{

string _myProperty;


public void MyMethod()

{

//方法

Console.WriteLine(" Current MyProperty:{0}",MyProperty);

}


公共字符串MyProperty

{

get {return _myProperty; }

set {_myProperty = value; }

}

}

---> 8 ---


保存作为''Lib.cs''并使用''csc / t:library Lib.cs''进行编译,你会得到
最终得到一个新的C#类Lib.dll库。


或者,用上面的文本替换VS

Express项目中主源文件的主体,然后从VS编译,你就'我会得到

a类似的结果,虽然名字不同(基于你的项目

名称)。


其他细节依赖在你的场景中。


- 巴里


-
http://barrkel.blogspot.com/


Peter Duniho写道:


2008年7月12日星期六15:10:07 -0700,Ikke< ik ** @ hier.bewrote:


> [...]
然而,Express Edition是我唯一的版本有,所以我会非常想知道如何自己添加这些方法和属性,
我认为*是*可能的(否则它将是相当愚蠢的
包括能力创建类库,imho)。

有人请你解释我是怎么做到的吗?或者指出我正确指导一个好的教程?



你可以手动输入它们。打开相应的.cs文件,其中

定义类并自行添加。


事实上,我很惊讶任何人都会使用GUI从头开始添加方法或

属性(与实现

接口所需的属性相反,覆盖现有方法等,IDE有足够的

保存一些实际打字的信息)。这样的功能增加了很少的价值,我甚至没有意识到它存在于VS. :)


Pete



我通过类图添加方法,属性等(也不是

在快递版中可用)我很喜欢它......但是我只是一个初学者并且非常感谢GUI,并确保我在第一时间做到正确。


给我们noobs它增加了很多价值,恕我直言。 :)


Todd


Hi everybody,

Using Microsoft Visual C# 2005 Express Edition, I''m trying to create a
class library (.dll) to include in a Delphi project.

Since I''m new to building .dlls, I''ve searched the internet and am now
following an example I''ve found at
http://www.dotnetheaven.com/Uploadfi...14101AM/pr12.a
spx , which explains how to build a .dll, and how to call it. So far so
good.

But when I come to the part of adding methods and properties, I''m asked
to right-click on the class-name and select ''Add->Add Method'' (or similar
for properties), which is not available in the Express Edition! I''ve
checked the internet again, and this is indeed not available in the EE.

However, the Express Edition is the only edition I have, so I would
really like to know how I can add these methods and properties myself,
which I assume *is* possible (otherwise it would be rather daft to
include the ability to create class libraries, imho).

Would anybody please care to explain to me how I do this? Or point me in
the right direction to a nice tutorial?

Thanks in advance!

Ikke

解决方案

On Sat, 12 Jul 2008 15:10:07 -0700, Ikke <ik**@hier.bewrote:

[...]
However, the Express Edition is the only edition I have, so I would
really like to know how I can add these methods and properties myself,
which I assume *is* possible (otherwise it would be rather daft to
include the ability to create class libraries, imho).

Would anybody please care to explain to me how I do this? Or point me in
the right direction to a nice tutorial?

You can just type them in manually. Open the appropriate .cs file where
the class is defined and add them yourself.

In fact, I''m amazed anyone would even use the GUI to add a method or a
property from scratch (as opposed to those required to implement an
interface, override an existing method, etc. where the IDE has enough
information to save some real typing). Such a feature adds so little
value that I didn''t even realize it existed in VS. :)

Pete


Ikke wrote:

Using Microsoft Visual C# 2005 Express Edition, I''m trying to create a
class library (.dll) to include in a Delphi project.

What is your point of integration with Delphi? Using Delphi for .NET?
(I work for CodeGear (now part of Embarcadero), on the Delphi compiler.)

In any case, programming is mostly a text-based discipline. I wouldn''t
waste time with GUI/menus/etc. for writing new code. Here''s a simple C#
class library:

---8<---
using System;
public class MyClass
{
string _myProperty;

public void MyMethod()
{
// a method
Console.WriteLine("Current MyProperty: {0}", MyProperty);
}

public string MyProperty
{
get { return _myProperty; }
set { _myProperty = value; }
}
}
--->8---

Save it as ''Lib.cs'' and compile with ''csc /t:library Lib.cs'', and you''ll
end up with a Lib.dll, a fresh new C# class library.

Alternatively, replace the body of the main source file in your VS
Express project with the above text, and compile from VS, and you''ll get
a similar result, albeit with a different name (based on your project
name).

Other details depend on your scenario.

-- Barry

--
http://barrkel.blogspot.com/


Peter Duniho wrote:

On Sat, 12 Jul 2008 15:10:07 -0700, Ikke <ik**@hier.bewrote:

>[...]
However, the Express Edition is the only edition I have, so I would
really like to know how I can add these methods and properties myself,
which I assume *is* possible (otherwise it would be rather daft to
include the ability to create class libraries, imho).

Would anybody please care to explain to me how I do this? Or point me in
the right direction to a nice tutorial?


You can just type them in manually. Open the appropriate .cs file where
the class is defined and add them yourself.

In fact, I''m amazed anyone would even use the GUI to add a method or a
property from scratch (as opposed to those required to implement an
interface, override an existing method, etc. where the IDE has enough
information to save some real typing). Such a feature adds so little
value that I didn''t even realize it existed in VS. :)

Pete

I add methods, properties, etc. via the class diagram (which is also not
available in the express edition) and I love it....but then I''m only a
beginner and appreciate the GUI making sure I get it right the first time.

To us "noobs" it adds a LOT of value, IMHO. :)

Todd


这篇关于如何添加方法和属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆