How to declare public static byte?
I have a class name constants where I put all the constant values in my project. I am also checking if the server is reachable all over my project. I want to declare a ip address in my constants so that I only change one and implement it in my project. I dont know how to declare the value in my constants class. What I need is below:
var ping = new Ping();
var reply = ping.Send(new IPAddress(Constants.ipaddress), 1500);
//I want to change 192,168,120,10 in the value in my constants
var ping = new Ping();
var reply = ping.Send(new IPAddress(new byte { 192, 168, 120, 10 }), 1500);
//What I declared in my constants
public static byte ipaddress;
c# xamarin xamarin.forms
add a comment |
I have a class name constants where I put all the constant values in my project. I am also checking if the server is reachable all over my project. I want to declare a ip address in my constants so that I only change one and implement it in my project. I dont know how to declare the value in my constants class. What I need is below:
var ping = new Ping();
var reply = ping.Send(new IPAddress(Constants.ipaddress), 1500);
//I want to change 192,168,120,10 in the value in my constants
var ping = new Ping();
var reply = ping.Send(new IPAddress(new byte { 192, 168, 120, 10 }), 1500);
//What I declared in my constants
public static byte ipaddress;
c# xamarin xamarin.forms
3
public static byte ipaddress = new byte { 192, 168, 120, 10 };
– Poul Bak
Nov 16 '18 at 2:07
@PoulBak He wants something that can't be changed. Even astatic readonly
won't be enough, since the content of the array can be modified.
– Corey
Nov 16 '18 at 2:12
@Corey Post your answer then.
– TerribleDog
Nov 16 '18 at 2:16
add a comment |
I have a class name constants where I put all the constant values in my project. I am also checking if the server is reachable all over my project. I want to declare a ip address in my constants so that I only change one and implement it in my project. I dont know how to declare the value in my constants class. What I need is below:
var ping = new Ping();
var reply = ping.Send(new IPAddress(Constants.ipaddress), 1500);
//I want to change 192,168,120,10 in the value in my constants
var ping = new Ping();
var reply = ping.Send(new IPAddress(new byte { 192, 168, 120, 10 }), 1500);
//What I declared in my constants
public static byte ipaddress;
c# xamarin xamarin.forms
I have a class name constants where I put all the constant values in my project. I am also checking if the server is reachable all over my project. I want to declare a ip address in my constants so that I only change one and implement it in my project. I dont know how to declare the value in my constants class. What I need is below:
var ping = new Ping();
var reply = ping.Send(new IPAddress(Constants.ipaddress), 1500);
//I want to change 192,168,120,10 in the value in my constants
var ping = new Ping();
var reply = ping.Send(new IPAddress(new byte { 192, 168, 120, 10 }), 1500);
//What I declared in my constants
public static byte ipaddress;
c# xamarin xamarin.forms
c# xamarin xamarin.forms
edited Nov 16 '18 at 2:04
Lawrence Agulto
asked Nov 16 '18 at 1:58
Lawrence AgultoLawrence Agulto
1158
1158
3
public static byte ipaddress = new byte { 192, 168, 120, 10 };
– Poul Bak
Nov 16 '18 at 2:07
@PoulBak He wants something that can't be changed. Even astatic readonly
won't be enough, since the content of the array can be modified.
– Corey
Nov 16 '18 at 2:12
@Corey Post your answer then.
– TerribleDog
Nov 16 '18 at 2:16
add a comment |
3
public static byte ipaddress = new byte { 192, 168, 120, 10 };
– Poul Bak
Nov 16 '18 at 2:07
@PoulBak He wants something that can't be changed. Even astatic readonly
won't be enough, since the content of the array can be modified.
– Corey
Nov 16 '18 at 2:12
@Corey Post your answer then.
– TerribleDog
Nov 16 '18 at 2:16
3
3
public static byte ipaddress = new byte { 192, 168, 120, 10 };
– Poul Bak
Nov 16 '18 at 2:07
public static byte ipaddress = new byte { 192, 168, 120, 10 };
– Poul Bak
Nov 16 '18 at 2:07
@PoulBak He wants something that can't be changed. Even a
static readonly
won't be enough, since the content of the array can be modified.– Corey
Nov 16 '18 at 2:12
@PoulBak He wants something that can't be changed. Even a
static readonly
won't be enough, since the content of the array can be modified.– Corey
Nov 16 '18 at 2:12
@Corey Post your answer then.
– TerribleDog
Nov 16 '18 at 2:16
@Corey Post your answer then.
– TerribleDog
Nov 16 '18 at 2:16
add a comment |
1 Answer
1
active
oldest
votes
Well, you could do
public static readonly byte ipaddress = new byte { 192, 168, 120, 10 };
var ping = new Ping();
var reply = ping.Send(new IPAddress(ipaddress), 1500);
However, I would encourage you to instead use the app.config for this information. That way, you can change the address without having to rebuild your project. If you choose to do that, store the address in standard dotted-quad format ("192.168.120.10"
) and use IPAddress.Parse
.
how to use IPAddress.parse?
– Lawrence Agulto
Nov 16 '18 at 2:12
@LawrenceAgulto Added a link
– D Stanley
Nov 16 '18 at 2:13
Will I have a problem in the future if I use byte instead of string?
– Lawrence Agulto
Nov 16 '18 at 2:14
I don't know what you mean by "problem", but you can't store a byte array in a config file, which is why I suggested using a string.
– D Stanley
Nov 16 '18 at 2:16
@DStanley FYI, noapp.config
for Xamarin.iOS|Android, and changing a file in a package would include at least a re-signing.
– SushiHangover
Nov 16 '18 at 4:10
add a comment |
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%2f53330412%2fhow-to-declare-public-static-byte%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Well, you could do
public static readonly byte ipaddress = new byte { 192, 168, 120, 10 };
var ping = new Ping();
var reply = ping.Send(new IPAddress(ipaddress), 1500);
However, I would encourage you to instead use the app.config for this information. That way, you can change the address without having to rebuild your project. If you choose to do that, store the address in standard dotted-quad format ("192.168.120.10"
) and use IPAddress.Parse
.
how to use IPAddress.parse?
– Lawrence Agulto
Nov 16 '18 at 2:12
@LawrenceAgulto Added a link
– D Stanley
Nov 16 '18 at 2:13
Will I have a problem in the future if I use byte instead of string?
– Lawrence Agulto
Nov 16 '18 at 2:14
I don't know what you mean by "problem", but you can't store a byte array in a config file, which is why I suggested using a string.
– D Stanley
Nov 16 '18 at 2:16
@DStanley FYI, noapp.config
for Xamarin.iOS|Android, and changing a file in a package would include at least a re-signing.
– SushiHangover
Nov 16 '18 at 4:10
add a comment |
Well, you could do
public static readonly byte ipaddress = new byte { 192, 168, 120, 10 };
var ping = new Ping();
var reply = ping.Send(new IPAddress(ipaddress), 1500);
However, I would encourage you to instead use the app.config for this information. That way, you can change the address without having to rebuild your project. If you choose to do that, store the address in standard dotted-quad format ("192.168.120.10"
) and use IPAddress.Parse
.
how to use IPAddress.parse?
– Lawrence Agulto
Nov 16 '18 at 2:12
@LawrenceAgulto Added a link
– D Stanley
Nov 16 '18 at 2:13
Will I have a problem in the future if I use byte instead of string?
– Lawrence Agulto
Nov 16 '18 at 2:14
I don't know what you mean by "problem", but you can't store a byte array in a config file, which is why I suggested using a string.
– D Stanley
Nov 16 '18 at 2:16
@DStanley FYI, noapp.config
for Xamarin.iOS|Android, and changing a file in a package would include at least a re-signing.
– SushiHangover
Nov 16 '18 at 4:10
add a comment |
Well, you could do
public static readonly byte ipaddress = new byte { 192, 168, 120, 10 };
var ping = new Ping();
var reply = ping.Send(new IPAddress(ipaddress), 1500);
However, I would encourage you to instead use the app.config for this information. That way, you can change the address without having to rebuild your project. If you choose to do that, store the address in standard dotted-quad format ("192.168.120.10"
) and use IPAddress.Parse
.
Well, you could do
public static readonly byte ipaddress = new byte { 192, 168, 120, 10 };
var ping = new Ping();
var reply = ping.Send(new IPAddress(ipaddress), 1500);
However, I would encourage you to instead use the app.config for this information. That way, you can change the address without having to rebuild your project. If you choose to do that, store the address in standard dotted-quad format ("192.168.120.10"
) and use IPAddress.Parse
.
edited Nov 16 '18 at 2:13
answered Nov 16 '18 at 2:09
D StanleyD Stanley
124k9116180
124k9116180
how to use IPAddress.parse?
– Lawrence Agulto
Nov 16 '18 at 2:12
@LawrenceAgulto Added a link
– D Stanley
Nov 16 '18 at 2:13
Will I have a problem in the future if I use byte instead of string?
– Lawrence Agulto
Nov 16 '18 at 2:14
I don't know what you mean by "problem", but you can't store a byte array in a config file, which is why I suggested using a string.
– D Stanley
Nov 16 '18 at 2:16
@DStanley FYI, noapp.config
for Xamarin.iOS|Android, and changing a file in a package would include at least a re-signing.
– SushiHangover
Nov 16 '18 at 4:10
add a comment |
how to use IPAddress.parse?
– Lawrence Agulto
Nov 16 '18 at 2:12
@LawrenceAgulto Added a link
– D Stanley
Nov 16 '18 at 2:13
Will I have a problem in the future if I use byte instead of string?
– Lawrence Agulto
Nov 16 '18 at 2:14
I don't know what you mean by "problem", but you can't store a byte array in a config file, which is why I suggested using a string.
– D Stanley
Nov 16 '18 at 2:16
@DStanley FYI, noapp.config
for Xamarin.iOS|Android, and changing a file in a package would include at least a re-signing.
– SushiHangover
Nov 16 '18 at 4:10
how to use IPAddress.parse?
– Lawrence Agulto
Nov 16 '18 at 2:12
how to use IPAddress.parse?
– Lawrence Agulto
Nov 16 '18 at 2:12
@LawrenceAgulto Added a link
– D Stanley
Nov 16 '18 at 2:13
@LawrenceAgulto Added a link
– D Stanley
Nov 16 '18 at 2:13
Will I have a problem in the future if I use byte instead of string?
– Lawrence Agulto
Nov 16 '18 at 2:14
Will I have a problem in the future if I use byte instead of string?
– Lawrence Agulto
Nov 16 '18 at 2:14
I don't know what you mean by "problem", but you can't store a byte array in a config file, which is why I suggested using a string.
– D Stanley
Nov 16 '18 at 2:16
I don't know what you mean by "problem", but you can't store a byte array in a config file, which is why I suggested using a string.
– D Stanley
Nov 16 '18 at 2:16
@DStanley FYI, no
app.config
for Xamarin.iOS|Android, and changing a file in a package would include at least a re-signing.– SushiHangover
Nov 16 '18 at 4:10
@DStanley FYI, no
app.config
for Xamarin.iOS|Android, and changing a file in a package would include at least a re-signing.– SushiHangover
Nov 16 '18 at 4:10
add a comment |
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.
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%2f53330412%2fhow-to-declare-public-static-byte%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
3
public static byte ipaddress = new byte { 192, 168, 120, 10 };
– Poul Bak
Nov 16 '18 at 2:07
@PoulBak He wants something that can't be changed. Even a
static readonly
won't be enough, since the content of the array can be modified.– Corey
Nov 16 '18 at 2:12
@Corey Post your answer then.
– TerribleDog
Nov 16 '18 at 2:16