Getting Started with Adobe After Effects - Part 6: Motion Blur
This module helps you to share, discuss and learn interview questions and answers of different technologies

C# - What are Named and Optional arguments?

Feb 7 2012 8:38PM by Manas Ranjan Dash   

Question

What are Named and Optional arguments in C#?

Answer

While passing the arguments you can associate a specific parmeter by its name rather than passing the argument by its position, this is what the Named argument does.

Also you can omit certain parameters which are called as Optional parameter.

The point here is even if you don't remember the parameter order and you know the parameter name than this way of passing the parameter without thinking about the order will help a lot. Also it improves the readability of the code.

For example( from MSDN)

CalculateBMI(weight: 123, height: 64);

CalculateBMI(height: 64, weight: 123);

N.B: A named argument can follow positional arguments. However, a positional argument cannot follow a named argument, this will cause a compiler error.

Read More..   [110 clicks]

Published under: C# Interview Questions and Answers ·  ·  ·  · 


Manas Ranjan Dash
39 · 5% · 1482
0
Liked
 
0
Asked



Submit

Your Comment


Sign Up or Login to post a comment.

"C# - What are Named and Optional arguments?" rated 5 out of 5 by 4 readers
C# - What are Named and Optional arguments? , 5.0 out of 5 based on 4 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]