Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to covert my feature class to feature layer so that i can pass "IQueryByLayer" over my feature class.

Till now i have my feature class ---

FeatureClass className = new FeatureClass(cc);

want to do something like

IFeatureLayer newLayer =

Can anybody point out a correct way to impliment it.

share|improve this question
Is this code running in an ArcMap addin/ ArcObjects custom class? – Devdatta Tengshe Jun 19 '13 at 10:02
No a destop tool where i am providing user to select two different feature classes//// – NewBee Jun 19 '13 at 11:12
up vote 1 down vote accepted

IFeatureLayer only make sense when your code is working within ArcMap. If that is your case, have a look at this code:

IFeatureLayer featureLayer = new FeatureLayerClass();
featureLayer.FeatureClass = featureWorkspace.OpenFeatureClass("2000_hrcn");
ILayer layer = (ILayer)featureLayer;
layer.Name = featureLayer.FeatureClass.AliasName;
// Add the layer to the focus map.
ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)(m_application.Document);
IMap map = mxDocument.FocusMap;
//now you can use the the IFeatureLayer

Also note that A featureclass cannot be instantiated directly. You can only get it as a result from other methods like IfeatureWorkspace.OpenFeatureClass method.

Code like FeatureClass className = new FeatureClass(cc); will not compile

share|improve this answer
I know i am getting it through IFeatureClass itration...Isn't there any way so that i can convert my feature class to layer and use it in IQueryByLayer... – NewBee Jun 19 '13 at 11:16
No, It will work only within ArcMap – Devdatta Tengshe Jun 19 '13 at 11:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.