How do I Compare two char[] arrays for equivalency?

前端 未结 5 504
眼角桃花
眼角桃花 2021-01-14 05:52

Right now, I have two char arrays, foo1[] and foo2[]. When I convert them to string and output to the console, they BOTH appear as

5条回答
  •  甜味超标
    2021-01-14 06:15

    you can make a function of yours which will be faster then first converting char[] to string then compare two strings. 1. First compare length of the arrays if they are not equal return false. 2. start looping through and compare each char, If you find any diff return false else after the loop return true.

    if(foo1.Length != foo2.Length){ return false;}
    for(int i=0;i

提交回复
热议问题