Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Got this class

C#
class Normale : IMathOperationDemo
    {
        decimal Alpha;
        decimal Beta;
        string mesatarja;
        string moda;
        string mesorja;
        string varianca;
        string Minimum;
        string Maximum;
        public string getMinimum(string Minimum)
    {
    Minimum.Value = Alpha.Value.ToString();
    return Minimum;
    }
        public string getMaximum(string Maximum)
        {
            Maximum.Value = Beta.Value.ToString();
            return Maximum;
        }
        public string GetMesatarja(string mesatarja)
        {
            mesatarja = (Alpha + Beta) / 2;
            return mesatarja.ToString
                                }
        public string GetMesorja(string mesorja)
        {
            mesorja = (Alpha + Beta) / 2;
            return mesorja.ToString;
        }
        public string GetModa(string moda)
        {
            moda = (Alpha + Beta) / 2;
            return moda.ToString;
        }
        public string GetVarianca(string varianca)
        {
            varianca = ((Beta-Alpha+1)*(Beta-Alpha+1)-1) / 12;
            return varianca.ToString;
        }
    }
}


Got errors :

'string' does not contain a definition for 'Value' and no extension method 'Value' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?

Cannot implicitly convert type 'decimal' to 'string'

What's wrong?

Please help

Regards
Posted

C#
public string GetMesatarja(string mesatarja)
{
    mesatarja =Convert.ToString((Alpha + Beta) / 2);
    return mesatarja;
}
public string GetMesorja(string mesorja)
{
    mesorja = Convert.ToString((Alpha + Beta) / 2);
    return mesorja;
}
public string GetModa(string moda)
{
    moda = Convert.ToString((Alpha + Beta) / 2);
    return moda;
}
public string GetVarianca(string varianca)
{
    varianca = Convert.ToString(((Beta-Alpha+1)*(Beta-Alpha+1)-1) / 12);
    return varianca;
}
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Jun-11 15:43pm    
Monjurul, can you see how useless all this is? How can it help OP? Whole thing makes no sense at all, and you cannot add any sense by fixing it.
Please see my answer.
--SA
Monjurul Habib 8-Jun-11 16:29pm    
yes that is the answer.
KORCARI 8-Jun-11 17:04pm    
SAKryukov thx anyway man. I don't get it why you become so upset but sorry. Just trying to learn from the more experienced ones
Sergey Alexandrovich Kryukov 8-Jun-11 18:06pm    
I'm not upset, I'm just sorry for you. I'm only upset that I cannot help you. You repeat the same function several time and probably cannot even see it. Please, for your own save, wake up and think thoroughly what are you doing.
--SA
KORCARI 9-Jun-11 2:38am    
I am not repeating it it is just some demo.
For me in this moment the most important is to extract from method to textbox even if inside methods is only a subtractions or add operations A+ B.
My second part of job is to realize some statistical distribution functions but this is my homework and I got to do it myself.
Anyway thx for the time spent over my posts
Regards
Whole thing is such a bad idea. You're trying to convert all calculations to string. This is pointless.
Again you certainly still have a big confusion on what is programming for.

Did you pay attention that Mesatarja, GetMesorja and Moda is the same very function under different names. Do you think that different names of arguments may make any difference.

I feel you misunderstood the very basics of elementary programming. You probably don't understand what a method, argument, variable do.
I don't know how to help here. You need to start with elementary course on programming and do very simple exercises to see how it works.

—SA
 
Share this answer
 
Comments
Monjurul Habib 8-Jun-11 16:21pm    
really good point, my 5.
Sergey Alexandrovich Kryukov 8-Jun-11 17:02pm    
Thank you, Monjurul.
Unfortunately, this is a hard case.
--SA
Monjurul Habib 8-Jun-11 16:23pm    
i should notice before, thank you --SA
Sergey Alexandrovich Kryukov 8-Jun-11 17:03pm    
See also the next question by OP -- same story, I also answered.
--SA
You are using ToString instead of ToString() I noticed.
Also in the steps where you are doing math, you should wrap with ToString().
For example:
C#
public string GetVarianca(string varianca)
{
    varianca = ((Beta-Alpha+1)*(Beta-Alpha+1)-1) / 12;
    return varianca.ToString;
}

will not work, but this will:
C#
public string GetVarianca(string varianca)
{
    return (((Beta-Alpha+1)*(Beta-Alpha+1)-1) / 12).ToString(); 
}

Because you are implicitly converting the results of a math function to a string "varianca"
You should probably check that the result won't throw an Exception, too. This is just to get you started.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 8-Jun-11 15:44pm    
Can you see how useless all this is? How can it help OP? Whole thing makes no sense at all, and you cannot add any sense by fixing it. You can only prolong the illusion that OP is programming something.
Please see my answer.
--SA
wizardzz 8-Jun-11 15:48pm    
I saw your answer, and it is more of a comment in my opinion. I could easily tear apart the OP every time I see a bad question from a beginner, but I wouldn't call it an answer.
Monjurul Habib 8-Jun-11 16:28pm    
We should consider as an answer.Because a programmer should learn the basic concepts of programming first.Beginner can not be an excuse.
wizardzz 8-Jun-11 16:29pm    
I'll start trying this approach on novice QA's in the future, though from my experience it will bring out some univoters.
Monjurul Habib 8-Jun-11 16:32pm    
apologize, i think you misunderstood me.Experts should help beginners but not with their wrong approach.
In this code:
public string getMinimum(string Minimum)
  {
  Minimum.Value = Alpha.Value.ToString();
  return Minimum;
  }


Minimum is string. you can not use Minimum.value=.... .
public string getMinimum(string Minimum)
  {
   return Alpha.ToString();
  }


Do the same for others.

the second problem is
public string GetMesatarja(string mesatarja)
        {
            mesatarja = (Alpha + Beta) / 2;
            return mesatarja.ToString
                                }

change it to
public string GetMesatarja(string mesatarja)
    {
        mesatarja = ((Alpha + Beta) / 2).ToString();
        return mesatarja;
                            }

and do the same for others.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900