vb-c#translation需要帮助 [英] Help needed in vb-c# translation

查看:88
本文介绍了vb-c#translation需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我将一些api'从vb代码移植到c#代码。

现在我想知道我如何翻译以下内容东西:

- 属性(我想没有什么比这更好了,我只想做一个方法

吧)

- 朋友(如在Friend Property Let LimitHeigh(ByVal vNewValue as Variant)

- Variant(就像在这里的相同例子,据我所知,

应该是从现在开始称为Object)


我也想知道我可以比较模块和类模块。

我一直在读关于Component,Interace和Abstract类,但我只是想知道我应该使用哪一个......


Thanx ...

解决方案

tiger79,


为了在C#中声明属性,您需要执行以下操作: br />

公共字符串MyProperty

{

get

{

返回你好;

}

套装

{

/ / mstrString是类中的一个字段。

mstrString = value;

}

}


基本上,它的形式如下:


< accessiblity level> <属性类型> < property name>

{

get

{

<获取属性值的代码>

}

设置

{

<设置属性值的代码>

}

}


至于朋友,使用内部关键字,它基本上允许

中的类在同一个项目中访问该字段。


对于变体类型使用Object,它可以存储任何内容。


如果你在模块中有代码,那么你应该可能创建一个类,

然后让类的方法是静态的(这样,它不会绑定到任何一个实例的
,就像模块中的函数一样没有)。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com


tiger79 < PO ** @ freemail.nl>在消息中写道

新闻:%2 ***************** @ TK2MSFTNGP10.phx.gbl ...

你好大家好,我正在把一些api'从vb代码移植到c#代码。
现在我想知道如何翻译以下内容:
- 属性(我猜那里是不是这样,我只会用它来制作一个方法

- 朋友(如在朋友财产中让LimitHeigh(ByVal vNewValue作为变体)
- Variant(如在这个例子就在这里,据我所知,
从现在起应该被称为对象。

我也想知道我可以比较模块和类模块。
我一直在阅读有关Component,Interace和Abstract类的内容,但我只是想知道我应该使用哪一个......

Thanx ...






很棒我只有一个关于物业声明的问题:

get方法非常简单那个set-method怎么样(或者

部分)?因为看着你的代码,在我看来你给mstrString分配了一个

的价值,但这个价值来自哪里?喜欢的方法:


public void ChangeSomething(string newValue)

{

something = newValue

}


这里我发送字符串newValue,因此它知道要分配给什么。

它在你的例子中是如何工作的?
再次
Thanx,其他信息非常有用!!! :D

Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com>写在

消息新闻:大江************** @ TK2MSFTNGP11.phx.gbl ...

tiger79,
为了在C#中声明属性,您需要执行以下操作:

公共字符串MyProperty
{
获取
{
return" hello";
}
设置
// mstrString是课堂上的一个字段。
mstrString = value;
}
}

基本上,它的形式如下:

< accessiblity level> <属性类型> < property name>
{
获取
{
<获取物业价值的代码>
}
设置
{
<代码设置属性值>
}

对于朋友,使用internal关键字,它基本上允许同一个项目中的
类访问那个字段。

对于变种类型使用一个Object,它可以在其中存储任何内容。

如果你在模块中有代码,那么你应该创建一个类,
然后让类的方法是静态的(这样,它不会绑定到任何一个实例,就像模块中的函数一样)。

希望这有助于。

-
- Nicholas Paldino [.NET / C#MVP]
- mv *@spam.guard.caspershouse.com

" tiger79" < PO ** @ freemail.nl>在消息中写道
新闻:%2 ***************** @ TK2MSFTNGP10.phx.gbl ...

大家好,现在我想知道我是如何翻译以下内容的:
- 属性(我想没有类似的东西)并且我只是制作一个方法


out

它的朋友(在朋友物业中让我们限制高度(ByVal vNewValue为
) Variant) - Variant(就像在这里的同一个例子,据我所知,
从现在起应该被称为Object)

我也想知道什么我可以比较模块和类模块。
我一直在阅读有关Component,Interace和Abstract类的内容,但我


只是

无法掌握哪一个(s) )我应该使用......

Thanx ...




tiger79,

Wh在您的属性声明的set部分中,value是一个

关键字。这是一个变量,表示从

右侧传入的值。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" tiger79" < PO ** @ freemail.nl>在消息中写道

news:%2 **************** @ tk2msftngp13.phx.gbl ...



我只有一个关于属性声明的问题:
get方法非常简单,但set-method(或
部分)怎么样?因为看着你的代码,在我看来你给mstrString
一个值,但是这个值来自哪里?喜欢在一个方法中:

public void ChangeSomething(string newValue)
{
something = newValue
}

这里我发送字符串newValue所以它知道要分配给什么。
在你的例子中它是如何工作的?
Thanx再次,其他信息非常有用!!! :D

Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com>在消息新闻中写了
:大江************** @ TK2MSFTNGP11.phx.gbl ...

tiger79,
为了在C#中声明属性,您需要执行以下操作:

公共字符串MyProperty
{
获取
{
返回"你好;
}
设置
// mstrString是班上的一个字段。
mstrString = value;
}
}

基本上,它的形式如下:

< accessiblity level> <属性类型> < property name>
{
获取
{
<获取物业价值的代码>
}
设置
{
<代码设置属性值>
}

对于朋友,使用内部关键字,它基本上允许类


在< blockquote class =post_quotes>访问该字段的相同项目。

对于变体类型使用Object,它可以在其中存储任何内容。

如果您有代码一个模块,然后你应该创建一个
类,

然后让类的方法是静态的(这样,它不是
绑定到任何一个实例,就像模块中的函数一样。

希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

; tiger79&曲OT; < PO ** @ freemail.nl>在消息中写道
新闻:%2 ***************** @ TK2MSFTNGP10.phx.gbl ...

大家好,现在我想知道我是如何翻译以下内容的:
- 属性(我想没有类似的东西)我只需要制作
方法

out out> blockquote class =post_quotes>
- 朋友(如朋友属性让LimitHeigh(ByVal vNewValue as


变体) - 变体(就像在这里的同一个例子,我有



发现应该从现在起称为Object)

我也想知道我可以比较模块和类
模块。我我一直在阅读关于Component,Interace和Abstract类的内容,但我


只是

无法掌握我应该使用哪一个......

Thanx ...





Hi everyone,
i''m porting some api''s from vb code to c# code.
Now i was wondering how i could be translating the following things :
- property (i guess there is nothing like it and i''ll just make a method out
of it)
- friend (as in Friend Property Let LimitHeigh(ByVal vNewValue as Variant)
- Variant (as in the same example up here, which as far as I have found
should be called Object from now on)

I''d also like to know with what I can compare Modules and Class Modules.
I''ve been reading about Component, Interace and Abstract classes but I just
cant grasp which one(s) I should be using...

Thanx...

解决方案

tiger79,

In order to declare a property in C#, you need to do the following:

public string MyProperty
{
get
{
return "hello";
}
set
{
// mstrString is a field on the class.
mstrString = value;
}
}

Basically, it is of the form:

<accessiblity level> <type of property> <property name>
{
get
{
<code to get property value>
}
set
{
<code to set property value>
}
}

As for friend, use the internal keyword, it basically allows classes in
the same project to access that field.

Use an Object for variant types, it can store anything in it.

If you have code in a Module, then you should probably create a class,
and then have the methods of the class be static (this way, it is not tied
to any one instance, like functions in a module are not).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tiger79" <po**@freemail.nl> wrote in message
news:%2*****************@TK2MSFTNGP10.phx.gbl...

Hi everyone,
i''m porting some api''s from vb code to c# code.
Now i was wondering how i could be translating the following things :
- property (i guess there is nothing like it and i''ll just make a method out of it)
- friend (as in Friend Property Let LimitHeigh(ByVal vNewValue as Variant)
- Variant (as in the same example up here, which as far as I have found
should be called Object from now on)

I''d also like to know with what I can compare Modules and Class Modules.
I''ve been reading about Component, Interace and Abstract classes but I just cant grasp which one(s) I should be using...

Thanx...





Great only I got a question about the property declaration :
the get method is quite straight-forward but how about the set-method (or
part) ? Because looking at ur code it seems to me u assign that mstrString a
value but where does that value come ? Like in a method :

public void ChangeSomething(string newValue)
{
something = newValue
}

here I send the string newValue so it knows what to assign to something.
How does it work in ur example ?
Thanx again, the other info has been very usefull !!! :D
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oe**************@TK2MSFTNGP11.phx.gbl...

tiger79,

In order to declare a property in C#, you need to do the following:

public string MyProperty
{
get
{
return "hello";
}
set
{
// mstrString is a field on the class.
mstrString = value;
}
}

Basically, it is of the form:

<accessiblity level> <type of property> <property name>
{
get
{
<code to get property value>
}
set
{
<code to set property value>
}
}

As for friend, use the internal keyword, it basically allows classes in the same project to access that field.

Use an Object for variant types, it can store anything in it.

If you have code in a Module, then you should probably create a class,
and then have the methods of the class be static (this way, it is not tied
to any one instance, like functions in a module are not).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tiger79" <po**@freemail.nl> wrote in message
news:%2*****************@TK2MSFTNGP10.phx.gbl...

Hi everyone,
i''m porting some api''s from vb code to c# code.
Now i was wondering how i could be translating the following things :
- property (i guess there is nothing like it and i''ll just make a method


out

of it)
- friend (as in Friend Property Let LimitHeigh(ByVal vNewValue as Variant) - Variant (as in the same example up here, which as far as I have found
should be called Object from now on)

I''d also like to know with what I can compare Modules and Class Modules.
I''ve been reading about Component, Interace and Abstract classes but I


just

cant grasp which one(s) I should be using...

Thanx...




tiger79,

When in the set section of your property declaration, "value" is a
keyword. This is a variable which represents the value passed in from the
right-hand side.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tiger79" <po**@freemail.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...



Great only I got a question about the property declaration :
the get method is quite straight-forward but how about the set-method (or
part) ? Because looking at ur code it seems to me u assign that mstrString a value but where does that value come ? Like in a method :

public void ChangeSomething(string newValue)
{
something = newValue
}

here I send the string newValue so it knows what to assign to something.
How does it work in ur example ?
Thanx again, the other info has been very usefull !!! :D
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Oe**************@TK2MSFTNGP11.phx.gbl...

tiger79,

In order to declare a property in C#, you need to do the following:

public string MyProperty
{
get
{
return "hello";
}
set
{
// mstrString is a field on the class.
mstrString = value;
}
}

Basically, it is of the form:

<accessiblity level> <type of property> <property name>
{
get
{
<code to get property value>
}
set
{
<code to set property value>
}
}

As for friend, use the internal keyword, it basically allows classes


in

the same project to access that field.

Use an Object for variant types, it can store anything in it.

If you have code in a Module, then you should probably create a class,

and then have the methods of the class be static (this way, it is not tied to any one instance, like functions in a module are not).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tiger79" <po**@freemail.nl> wrote in message
news:%2*****************@TK2MSFTNGP10.phx.gbl...

Hi everyone,
i''m porting some api''s from vb code to c# code.
Now i was wondering how i could be translating the following things :
- property (i guess there is nothing like it and i''ll just make a method

out

of it)
- friend (as in Friend Property Let LimitHeigh(ByVal vNewValue as


Variant) - Variant (as in the same example up here, which as far as I have


found should be called Object from now on)

I''d also like to know with what I can compare Modules and Class Modules. I''ve been reading about Component, Interace and Abstract classes but I


just

cant grasp which one(s) I should be using...

Thanx...





这篇关于vb-c#translation需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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