2 questions

  • Thread starter Thread starter Ced
  • Start date Start date
C

Ced

1. public void ExampleFunc(int param1, int? param2)

Does it mean that caller doesn't have to provide param2 when calling
ExampleFunc()?


2. internal void ExampleFunc(int param1, int? param2)

What does "internal" mean and when to use it?
 
Ced said:
1. public void ExampleFunc(int param1, int? param2)

Does it mean that caller doesn't have to provide param2 when calling
ExampleFunc()?

No. It means it's "nullable". If you want to omit it you still need to put
ExampleFunc(12345, null)

Otherwise it'd be

public void ExampleFunc(int param1, params int[] param2)

But then not only

ExampleFunc(12345)

will work but also

ExampleFunc(1,2,3,4,5)

Overloading might be a far better idea in most cases
What does "internal" mean and when to use it?

Internal funtions are visible only in your own project (assembly).
Help describes it pretty well. Look up "Accessibility Levels"

HTH
 
Hello Ced,
1. public void ExampleFunc(int param1, int? param2)

Does it mean that caller doesn't have to provide param2 when calling
ExampleFunc()?

Not it means he is allowed to pass null. normally won't accept null (as it's
a value type), but int? is internally wrapped as a Generic Nullable<int>.
You cannot leave it empty (unless there is an overload for ExampleFunc(int
param 1) as well.
2. internal void ExampleFunc(int param1, int? param2)

What does "internal" mean and when to use it?

Internal means that it is only available to other types that are in the same
assembly (so usually in the same Visual Studio project).
 
Back
Top