Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need Help Debugging my C# code, Per the images below, im getting the following e

ID: 3908328 • Letter: N

Question

Need Help Debugging my C# code, Per the images below, im getting the following errors with description in the textBox1_TextChanged(object sender, EventArgs e) where i am entering the information (pattern to search) and when i call the button9_Click(object sender, EventArgs e) which is the Rabin Karp algoirithm button. I want to inpiut the pattern in the text, run the algorithm by pressing the rabin karp button and display the results back to the main screen. What do i need to have written in the public void InputPattern(string text) to save what is written in? Would it be a read in code? And as for displaying the results back to the main screen [in this case it would be form 1], would i need a new method call like DisplayScreen?

StartT D Class1.cs Form1.cs Form1.cs [Design] ? Form 1 Brute Force Rabin Karp Boyer Moore Knuth Morris Pratt Heuristic Algorithm

Explanation / Answer

Dear Sir/Madam,

Please find the below reasons why you are getting errors.

Error 1:

In textBox_TextChanged(object sender, EventArgs e) we are creating object for Class1 class with zero arguments/parameters.

But Class1 constructor have one parameter/argument is name as type string. In your scenario you should pass string value.

That's why the error is throwing like "There is no argument given that corresponding to the required formal parameter 'name' of Class1.Class1(string)".

Solution:

During object creation you should pass a string to Class1 constructor like below.

Class1 enteredData=new Class1("string_value");

Error 2:

The remaining errors is about wrong way of method calling.

Actually RandomGenerator() method is not static method.

You are calling Class1.RandomGenerator() .You are calling method using class name. Static method can be called using Class name.

But in your scenario all three methods are non-static methods. So non-static method can be called using Class1 object.

Solution :

Please add static property to your three metods like below.

public static void RandomGenerator()

{

// your code....

}

public static void RabinKarp()

{

// your code....

}

public static void Display()

{

// your code....

}

So please follow the above steps.

Thank you and All the Best :)

With Regards,

Yoganjula Reddy G.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote