一个aspx页的类文件数 [英] No. of Class File for one aspx page

查看:80
本文介绍了一个aspx页的类文件数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

当我在Test_Page.aspx中创建页面时,将创建Test_Page.aspx.cs.
-是否可以为同一Test_Page创建另一个类文件.因为我的班级文件具有许多功能,所以我想将其拆分.
-如果是,请为我提供相同的指导(如何使用和访问它).
-如果没有,请原谅我,我是.Net的新手,并建议是否有其他替代方法.
问候,
AP

Dear Friends,

When I create a page in Test_Page.aspx, Test_Page.aspx.cs is created.
- Is it possible to create another class file for same Test_Page. Because my class file has many functions and I want to split it.
- If Yes, Kindly guide me for the same (How to use and access it).
- If No, Kindly forgive me, I am new to .Net and suggest if any alternate.

Regards,
AP

推荐答案

是的,可以尝试使用partial关键字.
类,结构和接口的partial类型定义是一个概念,可以将程序中的类型分成多个部分,以存储在不同的源文件中,以便于维护和开发.当需要使用嵌套类型或提供接口实现时,此方法特别有用.

看看下面的文章:
介绍C#2.0部分类型 [ C#语言功能,从C#2.0到4.0 [ ^ ]
http://msdn.microsoft.com/en-us/library/wa80x488 (v = vs.80).aspx [
Yes it is possible, try using partial keyword.
There is a concept of partial type definitions for classes, structs, and interfaces, as a means to break types in a program into multiple pieces to be stored in different source files for easier maintenance and development. This approach is particularly useful when the need arises to use nested types or provide interface implementation.

Have a look at below articles:
Introducing C# 2.0 Partial Types[^]
C# Language Features, From C# 2.0 to 4.0[^]
http://msdn.microsoft.com/en-us/library/wa80x488(v=vs.80).aspx[^]


这篇关于一个aspx页的类文件数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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