The structure is H−N≡C
Oxidation number of N is -1 because it is bonded to H and −2 because of the pi and sigma bonds with C.
There is no contribution from the coordinate bond which is the third bond to C in the structure, which gives us a total of −3.
Now let us suppose the oxidation number of ′C′ is x:
H−N≡C
1+ (-3) + x = 0
x = +2