This is how I have used it to copy an existing feature class into the memory geodatabase
MemoryConnectionProperties memoryConnectionProperties = new MemoryConnectionProperties();
var results = await QueuedTask.Run(async () =>
{
using (Geodatabase geodatabase = SchemaBuilder.CreateGeodatabase(memoryConnectionProperties))
{
var copyResult = await CopyFeatureClass(SelectedFCFeatureLayer.GetFeatureClass(), "memory", "VirtualInputLayer");
if (copyResult == null) return false;
using (FeatureClass virtualFC = geodatabase.OpenDataset<FeatureClass>("VirtualInputLayer"))
//rest of code
--------functions---------
public static async Task<IGPResult> CopyFeatureClass(FeatureClass InFC, string OutputPath, string OutputName, string SQLExpression = null, string FieldMap = null, string ConfigurationKeyword = null)
{
List<object> arguments = new List<object>
{
InFC, //Input features
OutputPath, //Output location
OutputName, //Output Name
SQLExpression, //Expression (optional)
FieldMap, //Field Map optional)
ConfigurationKeyword //Configuration Keyword (optional)
};
IGPResult result = await Geoprocessing.ExecuteToolAsync("conversion.FeatureClassToFeatureClass", Geoprocessing.MakeValueArray(arguments.ToArray()), null, null, null, GPExecuteToolFlags.None);
return result;
}