text: Count set bits in an integer | C # program to demonstrate __builtin_popcount ( ) ; Driver code
code: using System ; using System . Linq ; class GFG { public static void Main ( ) { Console . WriteLine ( Convert . ToString ( 4 , 2 ) . Count ( c = > c == '1' ) ) ; Console . WriteLine ( Convert . ToString ( 15 , 2 ) . Count ( c = > c == '1' ) ) ; } }