In this study, three different structures of two dimentional (2D) CxNy were investigated experimentally and theoretically to determine their wettability behavior and separation capability based on their porosity, surface defect structure, and surface energy. The C3N, C1N1, and graphitic-C3N4 (g-C3N4) were synthesized and coated on stainless steel mesh. Wettability characteristics of the C3N, C1N1, and g-C3N4-coated mesh showed hydrophobic/oleophilic, hydrophilic/ underwater super-oleophobic, and super-hydrophilic/underwater super-oleophobic, respectively. The experimental results showed that the best performance of C3N with the highest surface area was obsereved in oil removal and the best performance of g-C3N4 with the highest pyridinic-N/pyrrolic-N XPS peak-area ratio was observed in water removal. Since electrostatic interaction plays an important role in water-removing state, increasing the number of pyridinic-N increases the electrostatic potential of water with the surface during water removal. Based on surface energy calculations, the highest dispersed surface energy is found in C3N, whereas the strongest polar component is found in g-C3N4, confirming their hydrophobic and hydrophilic wettability, respectively. Density functional theory investigations confirmed the higher hydrophilicity of g-C3N4 due to its non-uniform electron density distribution. The adsorption energies of water and decalin molecules are proportional to the amounts of charge transfer between porous substrates and adsorbents.