如何在App_Code中调用class1.cs .. [英] How to call a class1.cs in App_Code ..

查看:120
本文介绍了如何在App_Code中调用class1.cs ..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在App_Code中有class1.cs,并且我想在其他地方使用该类属性.

i have class1.cs in App_Code and i want to use this class property in another place.

推荐答案

请看下面的链接.希望它能消除您对面向对象程序设计" 的疑问.

面向对象的编程基础

编辑-
从基础开始总是更好.

同样糟糕的是,同一个人在不到1/2小时的时间内多次问相同的问题.

这表示对已回答同一主题的上一个问题的人们的不尊重.

如果您不确定答案,那么您应该与解决方案提供商自行讨论,而不是再次发布相同的问题.
Have a look at below link. I hope it should clear your doubts regarding "Object Oriented Programming".

Object Oriented Programming Fundamentals

Edited -
It''s always better to start from basics.

Also its really bad, Same Person asking same Question multiple times within span of less than 1/2 Hour.

It''s shows disrespect towards the people who has Answered your previous Question on the same Topic.

If you are not clear with the Answer then you should discuss with the Solution Provider their it self, instead of posting same Question again.


您能否详细说明另一个地方"?我假设您的意思是其他项目".

App_code类是公共的,可以在Web项目中的任何位置使用.
如果要在Web项目外部(在解决方案中的其他项目中)使用类,请将该类移到单独的类库项目中,并在需要该类的任何地方(Web项目或其他项目)进行引用.
Could you please elaborate "another place"? I am assuming you mean "other project".

App_code classes are public and can be used anywhere within web project.
If you want to use the class outside web project (in other project in your solution) then move the class into a separate class library project and reference it wherever you need the class (web project or the other project).


二十分钟前发布时,您已经有了答案:
You have already had an answer to this when you posted it twenty minutes ago: how to call class1.cs class on page[^]

To reiterate Abhinav''s response:

If you have created a class called class1 in you App_code folder, then in your page.cs all you have to do is declare an instance of class1 and use it as normal. Alternatively, as Abhinav said, you could declare static methods and properties and use those directly, just as you would with an other class.

Why is this giving you a problem?
Use the "Reply" feature below this answer to respond - do not create a new question.


这篇关于如何在App_Code中调用class1.cs ..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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