Check if a number starts with another number or not | C # program for the above approach ; Function to check if B is a prefix of A or not ; Convert numbers into Strings ; Check if s2 is a prefix of s1 or not using starts_with ( ) function ; If result is true , print " Yes " ; Driver code ; Given numbers ; Function call
using System . Threading ; using System . Globalization ; using System ; class GFG { static void checkprefix ( int A , int B ) { string s1 = A . ToString ( ) ; string s2 = B . ToString ( ) ; bool result ; result = s1 . StartsWith ( s2 , false , CultureInfo . InvariantCulture ) ; if ( result ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } static void Main ( ) { int A = 12345 , B = 12 ; checkprefix ( A , B ) ; } }