elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


  Mostrar Temas
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / problemas con el c# en: 7 Septiembre 2008, 07:03 am
Bunes soy nuevo por aqui, tengo un problema con el c# ya que recien toy aprendiendolo, pienso que el error es muy simple pero no logro dar con el espero que alguien pueda ayudarme. el error esta en la cuando quiero que imprima la respuesta en el txtrpta   METODO EXPONENCIAL "Error   1 Se requiere una referencia a objeto para el campo, método o propiedad no estáticos 'metodos_1.Form1.txtrpta'".
Esta en .net 2005 espero sus respuestas                           



 static void Main()
      {
         Application.Run(new Form1());
      }

      private void btneje_Click(object sender,   System.EventArgs e)
      {
              double x=Convert.ToDouble(txtx.Text);
         double error=Convert.ToDouble(txterror.Text);
         exponencial(x,error);
      }
      public static double exponente(double x, int n)
      {
         int i;
         double result = 1;
         if (x == 0) return 0;
         for (i = 1; i <= n; i++)
            result = result * x;
         return result;
      }
      public static double factorial(int x)
      {
         int i;
         double fact = 1;
         for (i = 1; i <= x; i++)
            fact = fact* i;
         return fact;
      }
      private static double absoluto(double x)
      {
         if(x<0){
            x=-1*x;}
         return x;
      }
          private static double exponencial(double x, double error)
          {
              double Nerror=10000000;
              int n=2;
              double lastresult, result;
                while(Nerror>error)
                  {
                    lastresult=result;
                    result+=exponente(x,n)/factorial(n);n++;
                    Nerror=absoluto(Nerror-error);
==>  error    txtrpta.Text ="Paso"+n.ToString()+"\r\n   Valor:"+result.ToString()                  +"error:"+Nerror.ToString()+"\r\n ---------- \r\n";
                    if(n>100)
                    {MessageBox.Show("El sistema se detendá. muchas iteraciones");Nerror=0;}
                  }            
           }

Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines