C# How to find from a List of data a Geometry Class? and check if is not None?

Could someone explain How you could write this Python code in C# script?

import rhinoscriptsyntax as rs

for m in data:
if(m!=None and rs.IsCurve(m)):
curve = m

I try this but did not work:

private void RunScript(System.Object data, ref object A)
if (data != null){
Print(" Great, Data is not Null! “);
Print(” I found data");

// not work
  if (data ==  Rhino.DocObjects.Custom.CustomCurveObject){ 
    Print(" I found an Object Curve ");
    A = data; // data is a Curve!

var curves = new List<Curve>();
foreach(var m in data)
   Curve c = null;
   if(GH_Convert.ToCurve(m, ref c, GH_Conversion.Both))
A = curves;

GetCurves.gh (7.7 KB)

Dear Mahdiyar!
Thanks for your answer!

This Grasshopper API is new for me
GH_Convert.ToCurve Method

There is not a method to do this in RhinoCommon?

if(m is Curve c)