S
shapper
Hello,
I have a class, TweetService, with many methods which all use a
Twiiter object:
public class TwitterService : ITwitterService {
private const Twitter twitter = new Twitter("myusername",
"mypassword");
public void Create(Tweet tweet) {
TwitterStatus status = twitter.Status.Update
(tweet.Text);
} // Create
// Other methods
}
Is it correct to define it as a const?
Or should I just define it as follows:
private Twitter twitter;
And then initialized it on the TwitterService constructor:
public TwitterService() {
twitter = new Twitter("myusername", "mypassword");
} // TwitterService
Or some other way?
I just want twitter to be available to all methods and not having to
define it all the time and having the username and password every
where.
Thanks,
Miguel
I have a class, TweetService, with many methods which all use a
Twiiter object:
public class TwitterService : ITwitterService {
private const Twitter twitter = new Twitter("myusername",
"mypassword");
public void Create(Tweet tweet) {
TwitterStatus status = twitter.Status.Update
(tweet.Text);
} // Create
// Other methods
}
Is it correct to define it as a const?
Or should I just define it as follows:
private Twitter twitter;
And then initialized it on the TwitterService constructor:
public TwitterService() {
twitter = new Twitter("myusername", "mypassword");
} // TwitterService
Or some other way?
I just want twitter to be available to all methods and not having to
define it all the time and having the username and password every
where.
Thanks,
Miguel