为什么webmethod必须在asp.net中是静态的(C#) [英] Why webmethod have to be static in asp.net (C#)

查看:194
本文介绍了为什么webmethod必须在asp.net中是静态的(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

heyy ..





我想知道为什么webmethod必须是静态的?(在ajax jquery中),为什么要这样做?提供



方法中的静态关键字..?

解决方案

静态方法只是一个与其包含类的任何实例解除关联。更常见的替代方法是实例方法,该方法的结果取决于它所属类的特定实例的状态。



关键区别要理解的是,可以在不设置其所属类的正确实例的情况下调用静态方法。从某种意义上说,它是无状态方法



欲了解更多信息:



为什么ASP.NET AJAX页面方法必须是静态的?



我希望这会有所帮助你

heyy..


I want to known that Why webmethod have to be static?(in ajax jquery),why should be provide

static keyword in methods..?

解决方案

A static method is simply one that is disassociated from any instance of its containing class. The more common alternative is an instance method, which is a method whose result is dependent on the state of a particular instance of the class it belongs to.

The key difference to understand is that a static method can be called without setting up a proper instance of the class it belongs to.In a sense, it is a stateless method.

For more info :

Why do ASP.NET AJAX page methods have to be static?

I hope this will help to you.


这篇关于为什么webmethod必须在asp.net中是静态的(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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