In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what are the types of C#parameters". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "what are the types of C#parameters"!
C#Parameter Type
◆ Value parameter: does not contain any modifiers. A parameter in a method is a copy of the argument, and changes to the parameter do not affect the value of the argument in memory, so the argument is safe.
Reference parameters: declared with ref modifier. Parameters passed are actually pointers to arguments, so operations in methods are performed directly on arguments rather than copying a value; parameters can be passed bidirectionally in method calls using this method; in order to use parameters as ref, the ref keyword must be explicitly specified in both the method declaration and method call, and argument variables must be initialized before being passed to methods.
Output parameters: declared with the out modifier. Like ref, it operates directly on arguments. The out keyword must be explicitly specified in both method declarations and method invocations. The out parameter declaration does not require initialization of the variable before it is passed to the method, since it is meant only for output purposes. However, the out parameter must be assigned before the method returns.
Array parameters: declared with the params modifier. The params keyword is used to declare variable length parameter lists. A method declaration can contain only one params parameter.
C#Parameter Type Code
using System; class Test { static void F (params int[] args){ Console.WriteLine ("Array contains {0} elements:",args.Length); foreach (int i in args) Console.Write("{0}",i); Console.WriteLine(); } public static void Main(){ int [] a = {1,2,3}; F(a); F (10,20,30,40); F(); } } At this point, I believe that everyone has a deeper understanding of "what are the types of C#parameters". Let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.