edictText1 - This is Plain Text (where I enter the data as a console)

EditText editText1 = FindViewById<EditText>(Resource.Id.editText1); int ba = Int32.Parse(editText1.Text); 

If you enter data, say a unit, then it does not spars it. What is the problem, who knows? Maybe there is a method that parses fine? I work in Xamarin.Android

  • And what does "not parsit" mean? What's happening? - VladD
  • Well, i.e. it does not translate from Editable (this is the EditText format) to Int. I enter the data from the telephone keypad and he had to do a mathematical operation with this data and display it in response. In the end, he does not display anything to me, because data is not translated into Int - Daniil
  • Strange. If the number failed to parse, an exception should have been thrown. And what does the debugger show? - VladD
  • He tells me that he could not convert the number. This is what you get when running on the phone: System.FormatException - Daniil
  • This I have already moved away from the logic itself and tried to identify an error. So this is with Parse itself, and if I use TryParse, it will always give out False (even if I enter a number). - Daniil

1 answer 1

Use editText1.Text.ToString(); to get the string, not the text and parse.

And so translate the logic of parsing and calculating into the Core (Xamarin PCL / Net.Standard) project and use parsing operations from line to number abstracted from the platform. You may need this for other projects (iOS, UWP) in this application.

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/how-to-convert-a-string-to-a-number

Plus diagnostics:
You can create a variable before

 var inputedText = editText1.Text.ToString(); 

and bring it to the console.

 using System.Diagnostics; Debug.WriteLine(inputedText); 
  • Thanks a lot, I tried to use editText1.getText (). ToString () I can’t understand why it didn’t work, it turns out it works only in Java. Thank! - Daniil