Casting Issue | I am trying to return a similar type
up vote
3
down vote
favorite
I have an ObservableCollection UrlsList. I also have a checkbox in my WPF application which amends items in a list using the IsChecked property. The problem I am having is when I write some lambda expressions to filter the data I want I can't assign it back to UrlsList. It just sets my list to null which then crashes the application. Thanks for your help.
ViewModel
public ObservableCollection<URLModel> UrlsList { get; set; } = new ObservableCollection<URLModel>();
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = UrlsList.Select(url => url.ExistsInDb) as ObservableCollection<URLModel>;
else
UrlsList = UrlsList.Select(n => n.ExistsInDb == false) as ObservableCollection<URLModel>;
}
c# oop lambda
add a comment |
up vote
3
down vote
favorite
I have an ObservableCollection UrlsList. I also have a checkbox in my WPF application which amends items in a list using the IsChecked property. The problem I am having is when I write some lambda expressions to filter the data I want I can't assign it back to UrlsList. It just sets my list to null which then crashes the application. Thanks for your help.
ViewModel
public ObservableCollection<URLModel> UrlsList { get; set; } = new ObservableCollection<URLModel>();
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = UrlsList.Select(url => url.ExistsInDb) as ObservableCollection<URLModel>;
else
UrlsList = UrlsList.Select(n => n.ExistsInDb == false) as ObservableCollection<URLModel>;
}
c# oop lambda
1
URLModel
is not a bool, its as simple as that, you are trying to push round pegs in square holes
– TheGeneral
Nov 12 at 10:09
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have an ObservableCollection UrlsList. I also have a checkbox in my WPF application which amends items in a list using the IsChecked property. The problem I am having is when I write some lambda expressions to filter the data I want I can't assign it back to UrlsList. It just sets my list to null which then crashes the application. Thanks for your help.
ViewModel
public ObservableCollection<URLModel> UrlsList { get; set; } = new ObservableCollection<URLModel>();
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = UrlsList.Select(url => url.ExistsInDb) as ObservableCollection<URLModel>;
else
UrlsList = UrlsList.Select(n => n.ExistsInDb == false) as ObservableCollection<URLModel>;
}
c# oop lambda
I have an ObservableCollection UrlsList. I also have a checkbox in my WPF application which amends items in a list using the IsChecked property. The problem I am having is when I write some lambda expressions to filter the data I want I can't assign it back to UrlsList. It just sets my list to null which then crashes the application. Thanks for your help.
ViewModel
public ObservableCollection<URLModel> UrlsList { get; set; } = new ObservableCollection<URLModel>();
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = UrlsList.Select(url => url.ExistsInDb) as ObservableCollection<URLModel>;
else
UrlsList = UrlsList.Select(n => n.ExistsInDb == false) as ObservableCollection<URLModel>;
}
c# oop lambda
c# oop lambda
edited Nov 12 at 10:20
asked Nov 12 at 10:02
steve
477
477
1
URLModel
is not a bool, its as simple as that, you are trying to push round pegs in square holes
– TheGeneral
Nov 12 at 10:09
add a comment |
1
URLModel
is not a bool, its as simple as that, you are trying to push round pegs in square holes
– TheGeneral
Nov 12 at 10:09
1
1
URLModel
is not a bool, its as simple as that, you are trying to push round pegs in square holes– TheGeneral
Nov 12 at 10:09
URLModel
is not a bool, its as simple as that, you are trying to push round pegs in square holes– TheGeneral
Nov 12 at 10:09
add a comment |
2 Answers
2
active
oldest
votes
up vote
6
down vote
accepted
Your problem is you are seemingly using Select
instead of Where
The following produces a list an IEnumerable<bool>
UrlsList.Select(url => url.ExistsInDb)
What it seems you want is actually Where
, Which filters the list
UrlsList.Where(url => url.ExistsInDb);
Enumerable.Select Method
Projects each element of a sequence into a new form.
Enumerable.Where Method
Filters a sequence of values based on a predicate.
add a comment |
up vote
1
down vote
You are trying to cast an IEnumerable<T>
back to an ObservableCollection<T>
. That is bound to fail, because the value returned by a LINQ yuery is not an observable collection.
There are a couple of issues with your code:
- You are using
Enumerable.Select
when you should useEnumerable.Where
.Select
projects a list to a list with different values (which is not what you want), whileWhere
will filter your list, (which is what you want). - A LINQ query has to be materialized, for example with
Enumerable.ToList
orEnumerable.ToArray
. The result ofWhere
is a non-materializedIEnumerable
, whose execution is deferred. YourObservableCollection
is a full collection. - You can not materialize your LINQ query with a type cast. You have to create the collection yourself.
Considering all of those issues, your code would be:
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
else
UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => !url.ExistsInDb));
}
A more subtle bug in this code is however that when you check and then uncheck your check box, your URL list will be empty, because you first select only the checked items into the list and then select the non-checked items from that list. Since you have filtered the list already for the checked items, your second select will yield no result. You will have to store the original list somewhere else and select from there:
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = new ObservableCollection<URLModel>(allUrls.Where(url => url.ExistsInDb));
else
UrlsList = new ObservableCollection<URLModel>(allUrls.Where(url => !url.ExistsInDb));
}
Another issue is, that unless you modify the list somewhere else, you won't need an ObservableCollection
, since you are reassigning the list when the check box changes. You could either use a simple List<T>
or array, or - and that is what databinding is actually intended for - you change the content of the databound ObservableCollection
and then the UI would automatically change with it.
Thanks Sefe, that is a very descriptive anwswer. Even pointing out the bug that would unfold which I also missed. Now I am gettingurl.ExistsInDb=error CS0103: The name 'url' does not exist in the current context
. I really do not understand why this is happen when url is just a temporary variable being used inside the lamba expression?
– steve
Nov 12 at 10:46
Could it be that you are writingn => !url.ExistsInDb
? You declare the variable to the left of the lambda operator and use it to the right. The name has to match.
– Sefe
Nov 12 at 10:55
url => !url.ExistsInDb
this is what I am using. Thats the only way I know how to use lambda expressions :(.
– steve
Nov 12 at 10:58
What is the code that produces the error?
– Sefe
Nov 12 at 11:23
if (URLModel.IsChecked) UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
This piece. Saying url does not exist in the current context. my UrlList is initialised within the class.
– steve
Nov 12 at 11:25
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259796%2fcasting-issue-i-am-trying-to-return-a-similar-type%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
Your problem is you are seemingly using Select
instead of Where
The following produces a list an IEnumerable<bool>
UrlsList.Select(url => url.ExistsInDb)
What it seems you want is actually Where
, Which filters the list
UrlsList.Where(url => url.ExistsInDb);
Enumerable.Select Method
Projects each element of a sequence into a new form.
Enumerable.Where Method
Filters a sequence of values based on a predicate.
add a comment |
up vote
6
down vote
accepted
Your problem is you are seemingly using Select
instead of Where
The following produces a list an IEnumerable<bool>
UrlsList.Select(url => url.ExistsInDb)
What it seems you want is actually Where
, Which filters the list
UrlsList.Where(url => url.ExistsInDb);
Enumerable.Select Method
Projects each element of a sequence into a new form.
Enumerable.Where Method
Filters a sequence of values based on a predicate.
add a comment |
up vote
6
down vote
accepted
up vote
6
down vote
accepted
Your problem is you are seemingly using Select
instead of Where
The following produces a list an IEnumerable<bool>
UrlsList.Select(url => url.ExistsInDb)
What it seems you want is actually Where
, Which filters the list
UrlsList.Where(url => url.ExistsInDb);
Enumerable.Select Method
Projects each element of a sequence into a new form.
Enumerable.Where Method
Filters a sequence of values based on a predicate.
Your problem is you are seemingly using Select
instead of Where
The following produces a list an IEnumerable<bool>
UrlsList.Select(url => url.ExistsInDb)
What it seems you want is actually Where
, Which filters the list
UrlsList.Where(url => url.ExistsInDb);
Enumerable.Select Method
Projects each element of a sequence into a new form.
Enumerable.Where Method
Filters a sequence of values based on a predicate.
edited Nov 12 at 10:22
answered Nov 12 at 10:12
TheGeneral
26.6k63163
26.6k63163
add a comment |
add a comment |
up vote
1
down vote
You are trying to cast an IEnumerable<T>
back to an ObservableCollection<T>
. That is bound to fail, because the value returned by a LINQ yuery is not an observable collection.
There are a couple of issues with your code:
- You are using
Enumerable.Select
when you should useEnumerable.Where
.Select
projects a list to a list with different values (which is not what you want), whileWhere
will filter your list, (which is what you want). - A LINQ query has to be materialized, for example with
Enumerable.ToList
orEnumerable.ToArray
. The result ofWhere
is a non-materializedIEnumerable
, whose execution is deferred. YourObservableCollection
is a full collection. - You can not materialize your LINQ query with a type cast. You have to create the collection yourself.
Considering all of those issues, your code would be:
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
else
UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => !url.ExistsInDb));
}
A more subtle bug in this code is however that when you check and then uncheck your check box, your URL list will be empty, because you first select only the checked items into the list and then select the non-checked items from that list. Since you have filtered the list already for the checked items, your second select will yield no result. You will have to store the original list somewhere else and select from there:
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = new ObservableCollection<URLModel>(allUrls.Where(url => url.ExistsInDb));
else
UrlsList = new ObservableCollection<URLModel>(allUrls.Where(url => !url.ExistsInDb));
}
Another issue is, that unless you modify the list somewhere else, you won't need an ObservableCollection
, since you are reassigning the list when the check box changes. You could either use a simple List<T>
or array, or - and that is what databinding is actually intended for - you change the content of the databound ObservableCollection
and then the UI would automatically change with it.
Thanks Sefe, that is a very descriptive anwswer. Even pointing out the bug that would unfold which I also missed. Now I am gettingurl.ExistsInDb=error CS0103: The name 'url' does not exist in the current context
. I really do not understand why this is happen when url is just a temporary variable being used inside the lamba expression?
– steve
Nov 12 at 10:46
Could it be that you are writingn => !url.ExistsInDb
? You declare the variable to the left of the lambda operator and use it to the right. The name has to match.
– Sefe
Nov 12 at 10:55
url => !url.ExistsInDb
this is what I am using. Thats the only way I know how to use lambda expressions :(.
– steve
Nov 12 at 10:58
What is the code that produces the error?
– Sefe
Nov 12 at 11:23
if (URLModel.IsChecked) UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
This piece. Saying url does not exist in the current context. my UrlList is initialised within the class.
– steve
Nov 12 at 11:25
|
show 2 more comments
up vote
1
down vote
You are trying to cast an IEnumerable<T>
back to an ObservableCollection<T>
. That is bound to fail, because the value returned by a LINQ yuery is not an observable collection.
There are a couple of issues with your code:
- You are using
Enumerable.Select
when you should useEnumerable.Where
.Select
projects a list to a list with different values (which is not what you want), whileWhere
will filter your list, (which is what you want). - A LINQ query has to be materialized, for example with
Enumerable.ToList
orEnumerable.ToArray
. The result ofWhere
is a non-materializedIEnumerable
, whose execution is deferred. YourObservableCollection
is a full collection. - You can not materialize your LINQ query with a type cast. You have to create the collection yourself.
Considering all of those issues, your code would be:
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
else
UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => !url.ExistsInDb));
}
A more subtle bug in this code is however that when you check and then uncheck your check box, your URL list will be empty, because you first select only the checked items into the list and then select the non-checked items from that list. Since you have filtered the list already for the checked items, your second select will yield no result. You will have to store the original list somewhere else and select from there:
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = new ObservableCollection<URLModel>(allUrls.Where(url => url.ExistsInDb));
else
UrlsList = new ObservableCollection<URLModel>(allUrls.Where(url => !url.ExistsInDb));
}
Another issue is, that unless you modify the list somewhere else, you won't need an ObservableCollection
, since you are reassigning the list when the check box changes. You could either use a simple List<T>
or array, or - and that is what databinding is actually intended for - you change the content of the databound ObservableCollection
and then the UI would automatically change with it.
Thanks Sefe, that is a very descriptive anwswer. Even pointing out the bug that would unfold which I also missed. Now I am gettingurl.ExistsInDb=error CS0103: The name 'url' does not exist in the current context
. I really do not understand why this is happen when url is just a temporary variable being used inside the lamba expression?
– steve
Nov 12 at 10:46
Could it be that you are writingn => !url.ExistsInDb
? You declare the variable to the left of the lambda operator and use it to the right. The name has to match.
– Sefe
Nov 12 at 10:55
url => !url.ExistsInDb
this is what I am using. Thats the only way I know how to use lambda expressions :(.
– steve
Nov 12 at 10:58
What is the code that produces the error?
– Sefe
Nov 12 at 11:23
if (URLModel.IsChecked) UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
This piece. Saying url does not exist in the current context. my UrlList is initialised within the class.
– steve
Nov 12 at 11:25
|
show 2 more comments
up vote
1
down vote
up vote
1
down vote
You are trying to cast an IEnumerable<T>
back to an ObservableCollection<T>
. That is bound to fail, because the value returned by a LINQ yuery is not an observable collection.
There are a couple of issues with your code:
- You are using
Enumerable.Select
when you should useEnumerable.Where
.Select
projects a list to a list with different values (which is not what you want), whileWhere
will filter your list, (which is what you want). - A LINQ query has to be materialized, for example with
Enumerable.ToList
orEnumerable.ToArray
. The result ofWhere
is a non-materializedIEnumerable
, whose execution is deferred. YourObservableCollection
is a full collection. - You can not materialize your LINQ query with a type cast. You have to create the collection yourself.
Considering all of those issues, your code would be:
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
else
UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => !url.ExistsInDb));
}
A more subtle bug in this code is however that when you check and then uncheck your check box, your URL list will be empty, because you first select only the checked items into the list and then select the non-checked items from that list. Since you have filtered the list already for the checked items, your second select will yield no result. You will have to store the original list somewhere else and select from there:
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = new ObservableCollection<URLModel>(allUrls.Where(url => url.ExistsInDb));
else
UrlsList = new ObservableCollection<URLModel>(allUrls.Where(url => !url.ExistsInDb));
}
Another issue is, that unless you modify the list somewhere else, you won't need an ObservableCollection
, since you are reassigning the list when the check box changes. You could either use a simple List<T>
or array, or - and that is what databinding is actually intended for - you change the content of the databound ObservableCollection
and then the UI would automatically change with it.
You are trying to cast an IEnumerable<T>
back to an ObservableCollection<T>
. That is bound to fail, because the value returned by a LINQ yuery is not an observable collection.
There are a couple of issues with your code:
- You are using
Enumerable.Select
when you should useEnumerable.Where
.Select
projects a list to a list with different values (which is not what you want), whileWhere
will filter your list, (which is what you want). - A LINQ query has to be materialized, for example with
Enumerable.ToList
orEnumerable.ToArray
. The result ofWhere
is a non-materializedIEnumerable
, whose execution is deferred. YourObservableCollection
is a full collection. - You can not materialize your LINQ query with a type cast. You have to create the collection yourself.
Considering all of those issues, your code would be:
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
else
UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => !url.ExistsInDb));
}
A more subtle bug in this code is however that when you check and then uncheck your check box, your URL list will be empty, because you first select only the checked items into the list and then select the non-checked items from that list. Since you have filtered the list already for the checked items, your second select will yield no result. You will have to store the original list somewhere else and select from there:
public void CheckBoxOnClick()
{
if (URLModel.IsChecked)
UrlsList = new ObservableCollection<URLModel>(allUrls.Where(url => url.ExistsInDb));
else
UrlsList = new ObservableCollection<URLModel>(allUrls.Where(url => !url.ExistsInDb));
}
Another issue is, that unless you modify the list somewhere else, you won't need an ObservableCollection
, since you are reassigning the list when the check box changes. You could either use a simple List<T>
or array, or - and that is what databinding is actually intended for - you change the content of the databound ObservableCollection
and then the UI would automatically change with it.
edited Nov 12 at 10:56
answered Nov 12 at 10:28
Sefe
10.3k52242
10.3k52242
Thanks Sefe, that is a very descriptive anwswer. Even pointing out the bug that would unfold which I also missed. Now I am gettingurl.ExistsInDb=error CS0103: The name 'url' does not exist in the current context
. I really do not understand why this is happen when url is just a temporary variable being used inside the lamba expression?
– steve
Nov 12 at 10:46
Could it be that you are writingn => !url.ExistsInDb
? You declare the variable to the left of the lambda operator and use it to the right. The name has to match.
– Sefe
Nov 12 at 10:55
url => !url.ExistsInDb
this is what I am using. Thats the only way I know how to use lambda expressions :(.
– steve
Nov 12 at 10:58
What is the code that produces the error?
– Sefe
Nov 12 at 11:23
if (URLModel.IsChecked) UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
This piece. Saying url does not exist in the current context. my UrlList is initialised within the class.
– steve
Nov 12 at 11:25
|
show 2 more comments
Thanks Sefe, that is a very descriptive anwswer. Even pointing out the bug that would unfold which I also missed. Now I am gettingurl.ExistsInDb=error CS0103: The name 'url' does not exist in the current context
. I really do not understand why this is happen when url is just a temporary variable being used inside the lamba expression?
– steve
Nov 12 at 10:46
Could it be that you are writingn => !url.ExistsInDb
? You declare the variable to the left of the lambda operator and use it to the right. The name has to match.
– Sefe
Nov 12 at 10:55
url => !url.ExistsInDb
this is what I am using. Thats the only way I know how to use lambda expressions :(.
– steve
Nov 12 at 10:58
What is the code that produces the error?
– Sefe
Nov 12 at 11:23
if (URLModel.IsChecked) UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
This piece. Saying url does not exist in the current context. my UrlList is initialised within the class.
– steve
Nov 12 at 11:25
Thanks Sefe, that is a very descriptive anwswer. Even pointing out the bug that would unfold which I also missed. Now I am getting
url.ExistsInDb=error CS0103: The name 'url' does not exist in the current context
. I really do not understand why this is happen when url is just a temporary variable being used inside the lamba expression?– steve
Nov 12 at 10:46
Thanks Sefe, that is a very descriptive anwswer. Even pointing out the bug that would unfold which I also missed. Now I am getting
url.ExistsInDb=error CS0103: The name 'url' does not exist in the current context
. I really do not understand why this is happen when url is just a temporary variable being used inside the lamba expression?– steve
Nov 12 at 10:46
Could it be that you are writing
n => !url.ExistsInDb
? You declare the variable to the left of the lambda operator and use it to the right. The name has to match.– Sefe
Nov 12 at 10:55
Could it be that you are writing
n => !url.ExistsInDb
? You declare the variable to the left of the lambda operator and use it to the right. The name has to match.– Sefe
Nov 12 at 10:55
url => !url.ExistsInDb
this is what I am using. Thats the only way I know how to use lambda expressions :(.– steve
Nov 12 at 10:58
url => !url.ExistsInDb
this is what I am using. Thats the only way I know how to use lambda expressions :(.– steve
Nov 12 at 10:58
What is the code that produces the error?
– Sefe
Nov 12 at 11:23
What is the code that produces the error?
– Sefe
Nov 12 at 11:23
if (URLModel.IsChecked) UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
This piece. Saying url does not exist in the current context. my UrlList is initialised within the class.– steve
Nov 12 at 11:25
if (URLModel.IsChecked) UrlsList = new ObservableCollection<URLModel>(UrlsList.Where(url => url.ExistsInDb));
This piece. Saying url does not exist in the current context. my UrlList is initialised within the class.– steve
Nov 12 at 11:25
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259796%2fcasting-issue-i-am-trying-to-return-a-similar-type%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
URLModel
is not a bool, its as simple as that, you are trying to push round pegs in square holes– TheGeneral
Nov 12 at 10:09