调用私有构造函数 [英] calling a private constructor

查看:133
本文介绍了调用私有构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我创建了一个类也是一个构造函数(应该是其中一个条件)私有。

现在我应该在主程序。我的团队负责人说有一个技巧可以称之为。我可以调用变量j(因为它是静态的)。但不是con。

请帮帮我。

展开 | 选择 | Wrap | 行号

解决方案

这是C#。


我将它移到.NET论坛。


你需要为我认为的构造函数创建一个公共包装器


如此:

展开 | 选择 | Wrap | 行号


< blockquote class =post_quotes>
您需要为该构造函数创建一个公共包装器我认为


如此:

展开 < span class =codeDivider> | 选择 | Wrap | Line编号

Hello
I have created a class also a constructor which is (should be, one of the conditions) private.
Now I am supposed to call it in the main program. My team leader says there is a trick to call it. I can call the variable j(as it is static). but not con.
Please help me out.

Expand|Select|Wrap|Line Numbers

解决方案

This is C#.

I am moving this to the .NET forum.


You would need to make a public wrapper for that constructor I think

so like:

Expand|Select|Wrap|Line Numbers


You would need to make a public wrapper for that constructor I think

so like:

Expand|Select|Wrap|Line Numbers


这篇关于调用私有构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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