fundamental question: How can I call a static method inside another method. Please help!!
public static class Class1
{
public static string RenderCompareStatus()
{
bool isFound = Class1.Found(id);
}
private static bool Found(string id)
{
}
//Error message: does not contain definition for Found
I expanded your sample into a fully working example:
using System;
public static class Class1
{
public static void Main()
{
Console.WriteLine(RenderCompareStatus());
}
public static string RenderCompareStatus()
{
String id = "test";
bool isFound = Found(id);
return "Test: " + isFound;
}
private static bool Found(string id)
{
return false;
}
}
And the results:
Test: False
EDIT: If the above example is similar to your code but your code is not working, please edit your question, supplying more details such as the precise error you are getting and a more complete sample of the code that is producing the error.
EDIT: Changed public static bool Found(string id) to private static bool Found(string id) recompiled and it still works.
You use the class name
e.g. Class1.Found
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With