2 questions

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?
 
M

Michaela Julia

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
 
J

Jesse Houwing

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top