Reputation: 65
This is the code which i am using..
using PWServiceProxy
PortfolioQueryOptions Query = new PortfolioQueryOptions();
Query.PortfolioTypes = "Funded";
I am receiving an error such as
Cannot implicitly convert type string to PWServiceProxy.PortfolioTypes.
Upvotes: 0
Views: 2793
Reputation: 100238
Seems that Query.PortfolioTypes
is type of PWServiceProxy.PortfolioTypes
i.e. enum.
So you need to
Query.PortfolioTypes = PortfolioTypes.Funded;
or
string str = "Funded"; // or something else
PortfolioTypes pt;
if (Enum.TryParse(str, out pt))
Query.PortfolioTypes = pt;
else
throw new Exception("Can't parse input as PortfolioTypes");
Upvotes: 9
Reputation: 160852
Assuming PortfolioTypes
is an enum
with the name YourEnumType
try this :
Query.PortfolioTypes = (YourEnumType) Enum.Parse(typeof(YourEnumType), "Funded", true);
Upvotes: 1