Modifying the control point weight

Could somebody tell me shortly how can I modify a control point weight of a nurbs curve in RhinoCommon c#?
Thanks for your help.

private void RunScript(Curve crv, int i, double w, ref object A)
  var nurbs = crv.ToNurbsCurve();
  var loc = nurbs.Points[i].Location;
  nurbs.Points.SetPoint(i, loc, w);
  A = nurbs;
} (7.7 KB)