R−X+KCNalkylcyanide(attackoccursthroughC)RCNR−X+AgCNalkylisocyanide(attackoccursthroughN)R−NCAgCN is predominantly covalent, therefore, in this case only N-atom is free to donate electron pair. Thus, the attack mostly occurs through the N-atom of the cyanide group forming alkyl isocyanides. CN− behaves as an ambidentate nucleophile.