Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

If Textview is null or empty....

DimChrisDimChris USMember ✭✭✭✭
edited July 2016 in Xamarin.Android

Hi team! I'm beginner in xamarin's projects. So please be patient with me. Ι want to check if textview is null or empty.I'm using this code but it doesnt work.

        TextView textview2 = FindViewById<TextView>(Resource.Id.textView2);
        TextView textview1 = FindViewById<TextView>(Resource.Id.textView1);
        if (textview1 != null)
        {
            textview2.Text = "123";
        }
        else
        {

        }
Tagged:

Best Answer

Answers

  • sirvashsirvash ESMember

    try this:

          //empty              null               
      if (textview1.text ="" || textview1.text == null)
            {
              textview2.Text = "123";
            }
            else
            {
    
            }
    
  • DimChrisDimChris USMember ✭✭✭✭

    Operator '||' cannot be applied to operands of type 'string' and 'bool' App1

Sign In or Register to comment.