TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Praveen Kattepogu
NA
5
542
How to pass the local variable in a method to the other class?
Jun 28 2020 5:08 PM
I am pretty new to c# would somebody help me on this
How to pass the local variable in a method to the other class or a method?
using an event or a delegate,
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
using Timer = System.Timers.Timer;
namespace APPTest
{
public delegate MeterData meterdata();
public class Entry : Substation
{
public static event meterdata meterEvent;
private static Timer _timer;
static void SetTimer()
{
_timer = new Timer(1000);
_timer.Elapsed += _timer_Elapsed;
_timer.AutoReset = true;
_timer.Enabled = true;
}
private static void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
}
public void EnterData()
{
Raspberry_Connection();
SetTimer();
}
public void Raspberry_Connection() //
{
// var substation = new Substation() { IPAddress = "172.16.1.90", Topic = "raspberry_main", ConnectionStatus = true };
IPAddress = "172.16.1.90";
Topic = new[] { "raspberry_main", "raspberry_weather" };
Connected = true;
Mqttconnection();
MqttEvents += Substation_MqttEvents;
}
public void Substation_MqttEvents(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
{
var Topic_Message = System.Text.Encoding.UTF8.GetString(e.Message);
var Topic_DeserializeMessage = JsonConvert.DeserializeObject<MeterData>(Topic_Message);
try
{
// Console.WriteLine(Current_A);
// Console.WriteLine(tags.LastMonthPeak_TotalDemand_23AH);
//Console.WriteLine("23AH Real Power : {0}", Topic_DeserializeMessage.Tags.Real_Power_23_AH);
//Console.WriteLine("Weather cloud details :{0}", Topic_DeserializeMessage.detail);
//Console.WriteLine("Weather ID : {0}", Topic_DeserializeMessage.id);
//Console.WriteLine("Weather cloud weather :{0}", Topic_DeserializeMessage.weather);
}
catch (NullReferenceException ex)
{
}
}
}
}
Reply
Answers (
1
)
How to implement onion architecture in asp.net core
How to search the Text in Word document using C#