Question with C # options

I am new to C # and need help understanding what happens in the next function

public bool parse(String s) { table.Clear(); return parse(s, table, null); } 

where the table is the dictionary. I see that this is recursive, but how is parsing passed with three parameters when it is defined to take only a string?

EDIT: how to delete a question? parse was overwhelmed by facepalm

+6
c #
source share
5 answers

It is overloaded with parse exists, which takes 3 arguments.

+7
source share

No, this is not recursive.

This is a completely different function.

In C #, as well as C ++, different functions can have the same name. This is called overload.

+3
source share

Your code should have another definition that has an analysis method that takes three parameters. Right-click on “parsing” in the return line and select “Go to Definition” in visual studio to find it.

0
source share

Method overloading in class-based object-oriented languages ​​is a very useful tool. Methods are similar to functions (they have parameters, they return a value if they are not invalid, and they do some things), but they are part of a class (if they are static) or an object. The method is identified by the method signature. If you define two methods with the same name for a class or class objects, but the list of parameters is different, they become two different ways with the same name.

Advantages: 1.) If some methods basically do the same, you will recognize this from the very beginning because you give them exactly the same name. 2.) You can use overloading to solve many problems in a simple way that is very difficult to manage in languages ​​like C.

Recursion can happen if you call parse ("foo") there, because it will call the same function.

0
source share

The parsing function overloads. When overloading the same function, various work depending on the parameter can be performed.

The second analysis method, excluding 3 arguments.

0
source share

All Articles