Discussion:
WCF Service Application
(too old to reply)
Luuk
2015-11-28 14:44:56 UTC
Permalink
I am trying to create a webservice, so i starten Visual Studio 2015,
choose new Project, and picked 'WCF Service Application'

This seems to work, but examining the code, i see in IService.cs that
stringValue is initted with the value "Hello"

I do not see this value anywhere being used, can someone explain why
this initialization is done?


// Use a data contract as illustrated in the sample below to add
composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";

[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}

[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
Arne Vajhøj
2015-11-28 21:39:55 UTC
Permalink
Post by Luuk
I am trying to create a webservice, so i starten Visual Studio 2015,
choose new Project, and picked 'WCF Service Application'
This seems to work, but examining the code, i see in IService.cs that
stringValue is initted with the value "Hello"
I do not see this value anywhere being used, can someone explain why
this initialization is done?
// Use a data contract as illustrated in the sample below to add
composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
I don't initialize that way when I write a WCF service.

But VS 2012/2013/2015 wizards seems all to do so.

My guess is that it is to have some default value for
the generated service implementation.

If you have a working service then I think you can just delete
it.

Arne

Loading...