初始化类中的复数常量 [英] initialize a complex constant in a class
本文介绍了初始化类中的复数常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个类将用作实用程序类(它的所有函数都是共享的b $ b,不需要实例化它,让只是为了计算东西。
它需要一个常量字典(char,string),里面有46个条目,
用于它的所有共享功能。我如何自动实例化它只需一次,而不是在每个函数调用时创建它?
谢谢!
ibiza
解决方案
添加一个共享变量来保存字典并将其填入< br $>
类初始化器
例如
公共类别物品
私人共享_dict为HashTable
共享子新()
_dict = new ArrayList
''添加项目到HashTable
end sub
结束班
hth,
Alan 。
您可以将此公开为在共享的
构造函数中初始化的共享成员吗?
Patrice
-
" ibiza" < LA ****** @ gmail.com> écritdansle message de
news:11 ********************** @ f14g2000cwb.googlegr oups.com ...... < blockquote class =post_quotes>
我有一个类将用作实用程序类(它的所有函数共享,不需要实例化它,让我们说吧只计算事物)
它需要一个常量字典(char,string),其中包含46个条目,
用于所有共享函数。我怎样才能自动实例化
一次,而不是在每个函数调用时创建它?
谢谢!
ibiza
谢谢! :)
我猜你们都说了同样的话?
Hi,
I have a class which will be used as a utility class (all its functions
shared, no need to instantiate it, let''s say just to calculate things)
It needs a constant dictionary(of char, string) with 46 entries in it,
that is used in all its shared functions. How can I instantiate it
automatically only once, instead of creating it at each function call?
thanks!
ibiza
解决方案
Add a shared variable to hold the dictionary and populate it in the
class Initializer
e.g.
public class Something
private shared _dict as HashTable
shared sub new()
_dict = new ArrayList
'' Add the items to the HashTable
end sub
end class
hth,
Alan.
You could expose this as a shared member initialized in the shared
constructor ?
Patrice
--
"ibiza" <la******@gmail.com> a écrit dans le message de
news:11**********************@f14g2000cwb.googlegr oups.com...Hi,
I have a class which will be used as a utility class (all its functions
shared, no need to instantiate it, let''s say just to calculate things)
It needs a constant dictionary(of char, string) with 46 entries in it,
that is used in all its shared functions. How can I instantiate it
automatically only once, instead of creating it at each function call?
thanks!
ibiza
thanks! :)
I guess you both said the same thing?
这篇关于初始化类中的复数常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文